L
L
Legalas612017-03-13 03:04:13
selenium
Legalas61, 2017-03-13 03:04:13

Why Selenium webDriver can't find element on new page?

goButtomStart.Click();// Открываем новое окно
Brauser.SwitchTo().Window(Brauser.WindowHandles[1]);//переключаемся на него
System.Console.WriteLine(Brauser.Title + Brauser.Url);//Title и Url его

 //Поиск на новом окне
IWebElement cl = Brauser.FindElement(By.LinkText("Забыли пароль?")); //cl==null, элемент не найдет

Why can't find the element? If you run immediately at the URL of this page, then the code works. Am I switching from the main page to this page incorrectly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
netW0rm, 2017-03-13
@Legalas61

Perhaps the problem is that the page opens through a click, and the webdriver does not wait for the page to complete loading and continues to execute the code, but the element has not yet been "drawn". Pause before searching for an element

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question