Suicidalllama
Suicidalllama

Reputation: 53

Find element in table using XPath

I just started using selenium webdriver. I am trying to find an input field located in a table (can be found here https://i.sstatic.net/H1ZMt.jpg)

I've tried right clicking -> Copy -> Copy XPath, but when I start my program, i get the following error:

Unable to locate element: {"method":"xpath","selector":"/html/body/div/table[2]/tbody/tr[3]/td[2]/input"}

The input field I would like to find is the one called "loginanvid". Any help is appreciated.

Upvotes: 1

Views: 620

Answers (1)

cruisepandey
cruisepandey

Reputation: 29382

For switching to Iframe use this code:

IWebElement iframeEle = driver.FindElement(By.Name("main")); driver.SwitchTo().Frame(iframeEle);  

then use this Xpath :

//tr[@class='bgmork']/descendant::input[@name='loginanvid']

Upvotes: 2

Related Questions