I'm new to Selenium WebDriver and I am trying to write a simple script to log into a yahoo email account and then logout. I have managed to get the login part work working but I haven't been able to get the sign out part to work. I get the following error:
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate
element: {"method":"link text","selector":"Sign Out"}
I have tried the following 3 things so far: 1)
driver.findElement(By.linkText("Sign Out")).click();
2)
driver.findElement(By.partialLinkText("Sign Out")).click();
3)
WebElement element2 = driver.findElement(By.linkText("Sign Out"));
element2.submit();
I essentially get the same error in each case. I have pasted my code below. Any help would be appreciated.
FirefoxDriver driver = new FirefoxDriver();
driver.get("https://login.yahoo.com/config/login_verify2?.intl=ca&.src=ym");
driver.manage().window().maximize();
WebElement element = driver.findElement(By.id("username"));
element.sendKeys("myid@yahoo.com");
driver.findElement(By.id("passwd")).sendKeys("mypassword");
element.submit();
Thread.sleep(40000);
driver.findElement(By.linkText("Sign Out")).click();
Thread.sleep(40);
Use the script below, it will work: