Hello to you all;
I am a beginner in Selenium webdriver. I am trying to automate the LinkedIn page using selenium webdriver. Below is my code:
import
org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Login {
public static void main(String[] args) throws InterruptedException {
System.out.println("My name is Milo and I am testing Selenium WebDriver.");
WebDriver driver = new FirefoxDriver();
driver.get("
http://www.linkedin.com");
System.out.println(driver.getTitle());
System.out.println(driver.getCurrentUrl());
// Sign in to LinkedIn with Email Address and Password
WebElement emailAddress = driver.findElement(By.xpath("//*[@id='session_key-login']"));
emailAddress.sendKeys("
xxxxx...@xxx.com");
WebElement Password = driver.findElement(By.xpath("//*[@id='session_password-login']"));
Password.sendKeys("xxxxxxxxxxxxxx");
driver.findElement(By.xpath("//*[@id='signin']")).click();
System.out.println(driver.getCurrentUrl());
// Hold the program for 8 seconds
Thread.sleep(8000L);
// Sign out from LinkedIn
driver.findElement(By.xpath("//*[@id='img-defer-id-1-56424']")).click();
driver.findElement(By.xpath("//*[@id='account-sub-nav']/div/div[2]/ul/li[1]/div/span/span[3]/a")).click();
Here is the console result:
--------------------------------------
My name is Milo and I am testing Selenium WebDriver.
World's Largest Professional Network | LinkedIn
https://www.linkedin.com/http://www.linkedin.com/nhome/?trk=Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"//*[@id='img-defer-id-1-56424']"}
Command duration or timeout: 59 milliseconds