java - Selenium WebDriver not working fine on Amazon site -


i trying write selenium test against amazon site. want "sign in" element can click on it.

url: www.amazon.es

here selenium code:

system.setproperty("webdriver.gecko.driver","c:\\geckodriver-v0.18.0-win64\\geckodriver.exe"); webdriver driver = new firefoxdriver(); driver.get("https://www.amazon.es");  try {                driver.findelement(by.id("nav-link-accountlist")).click(); } catch (exception e) {     system.out.println("not found"); } 

sometimes code works correctly not find id "nav-link-youraccount". problem? , how can solve it?

provide few seconds of wait, before click webelement driver may able find webelement.

for wait using explicit wait method.

webdriverwait wait = new webdriverwait(driver,10); wait.until(expectedconditions.elementtobeclickable(driver.findelement(by.id("nav-link-accountlist"))));  driver.findelement(by.id("nav-link-accountlist")).click(); 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -