i have my html code looks like this:
Small error in your code, you're missing '' around the text "+linktext+"
:
driver.findElement(By.xpath("/table[contains(@class,'results ib-list')]/tbody/tr/td[@class = 'name']/a[contains(text(),'"+linktext+"')]")).click();
NoSuchElementException
usually means the element is in a frame
, or slow to load. Selenium only interacts with elements in the current frame. Any element within a child frame
cannot be interacted with until you switch into that frame
. You can switch by using switchTo().frame()
:
driver.switchTo().frame(ARG);
The arguments for frame()
are
frame
webelement
rerference of the frame
When done in the iframe
, use the following to exit back to the top of the document:
driver.switchTo().defaultContent();