selenium click on anchor tag inside table td

后端 未结 2 1793
梦如初夏
梦如初夏 2021-01-23 14:48

i have my html code looks like this:

2条回答
  •  暖寄归人
    2021-01-23 15:03

    As you have the link under a tag so selenium must work with below code. You xpath will be .//*[@id='food-search-all']/ul/li (assuming that div id is unique .You can take help with firebug for generate xpath )

    IWebElement TargetElement = driver.FindElement(By.XPath(xPathVal)); 
    string CellVal = TargetElement.Text.ToString(); 
    TargetElement = driver.FindElement(By.LinkText(CellVal));
    TargetElement.Click();
    

    sometimes sigle use of .Click() not work i will suggest add one more TargetElement.Click(); if your first try not work.

提交回复
热议问题