Nabeel_Afzal
Nabeel_Afzal

Reputation: 155

Unable to locate element error using selenium in C#

i m trying to get the element using selenium by id and by XPATH but in both cases unable to locate error occurs. Code:

IWebDriver dr = new ChromeDriver();
 dr.Navigate().GoToUrl("http://epaper.dawn.com/");
 IWebElement today = dr.FindElement(By.XPath("//*[@id='planetmap']"));

Code of the element is

I have tried both id and XPATH method

Upvotes: 0

Views: 1470

Answers (1)

alecxe
alecxe

Reputation: 473813

The desired element is inside an iframe, switch to it first:

dr.SwitchTo().Frame("DawnPaperFrame");
IWebElement today = dr.FindElement(By.XPath("//*[@id='planetmap']"));

Upvotes: 1

Related Questions