Question: I am trying to write a Selenium test against Amazon site. I want to get "Sign in" element so that I can click on it.

url: www.amazon.es

Here is my 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 the code works correctly but sometimes it does not find the ID "nav-link-yourAccount". What is the problem? and how can I solve it?

Answer: 
Instead using implicit wait try using **explicit** wait for the login element.

I've tried with explicit wait over 50 click and it did works.

**Here is code you can use.**

```
public class dump {
    public static void main(String a[]){
        System.setProperty("webdriver.gecko.driver","C:\\geckodriver-v0.18.0-win64\\geckodriver.exe");
        WebDriver driver = new FirefoxDriver();
        WebDriverWait wait = new WebDriverWait(driver, 15);
        for(int i=0; i<=50; i++){
            driver.get("https://www.amazon.es");
            try{    
                wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='nav-link-accountList']")));  
                driver.findElement(By.xpath("//*[@id='nav-link-accountList']")).click();
                System.out.println("clicked\t"+i);
            }catch (Exception e){
                e.printStackTrace();
                System.out.println("Not Found");
            }
        }

    }
}

```

**Here is the proof of run:**

[![enter image description here](https://i.stack.imgur.com/ruxUm.png)](https://i.stack.imgur.com/ruxUm.png)

All the best!!
Have you tried to find elements by xpath?

```
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.xpath("//*[@id='nav-link-accountList']")).click();

}catch (Exception e)
 {
        System.out.println("Not Found");

    }

```