-2

I'm doing a test on c# with selenium for this site http://onliner.by. At first I have to be authorized on this site.

I found(by xpath) button with name"Вход" in the right upper corner and click on it.

Then there's refreshed and page changed, but the link remained the same (http://onliner.by).

And I need to enter login and password on this page and sumbit it. But I cannot do it. I founded Xpath paths of this elements and I used this code:

//this doesn't work
driver.FindElement(By.XPath("//*[@id='auth-container__forms']/div/div[2]/form/div[1]/div[1]/input")).SendKeys("user");
driver.FindElement(By.XPath("//*[@id='auth-container__forms']/div/div[2]/form/div[1]/div[2]/input")).SendKeys("password");
driver.FindElement(By.XPath("//*[@id='auth-container__forms']/div/div[2]/form/div[3]/div/button")).Click();

How can I do it? I tried to use SwitchTo().Frame but it didn't help too.

I will be very grateful for help.

Image explanation what I need

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
  • 1
    https://stackoverflow.com/editing-help – Xpleria Nov 06 '17 at 09:13
  • Arrange question properly – iamsankalp89 Nov 06 '17 at 09:43
  • The username and password not in frame, so you no need to switch to frame. And I checked your xpath is correct. The possbile reason is you need to wait the login page loading complete before you can operate any element on it. Try add some sleep after click "Вход" in the right upper corner. – yong Nov 06 '17 at 14:44
  • Yeah, thank you very much) But SwitchTo().frame didn't require. WebDriverWait solved this trouble) – Aleksandr Efimov Nov 06 '17 at 15:52

1 Answers1

0

You have to wait element availablity like this

new WebDriverWait(driver, TimeSpan.FromSeconds(timeOut)).Until(ExpectedConditions.ElementExists((Locator Value)));
iamsankalp89
  • 4,607
  • 2
  • 15
  • 36