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 -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -

What is happening when Matlab is starting a "parallel pool"? -