Showing posts with label LinkedIn login. Show all posts
Showing posts with label LinkedIn login. Show all posts

Wednesday, June 25, 2014

Login/logout scenario for linkedin.

Note: Please give the your user id and password in highlighted place.

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class LinkedIn {
public static void main(String[] args) throws InterruptedException {
WebDriver driver=new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("https://www.linkedin.com/");
driver.findElement(By.id("session_key-login")).sendKeys("give_ur_userid_here");
driver.findElement(By.id("session_password-login")).sendKeys("give_ur_pass_here");
//driver.findElement(By.xpath("//input[@id='signin']")).click();
Actions act=new Actions(driver);
WebElement sign = driver.findElement(By.id("signin"));
act.moveToElement(sign).doubleClick().perform();
WebElement network = driver.findElement(By.xpath("//li[@class='nav-item']/a[contains(text(),'Connections')]"));
act.moveToElement(network).perform();
Thread.sleep(1000);
WebElement addConn = driver.findElement(By.xpath("//ul[@class='sub-nav']//a[contains(text(),'Add Connections')]"));
act.moveToElement(addConn).click().perform();
WebElement img = driver.findElement(By.xpath("//img[@class='img-defer nav-profile-photo']"));
act.moveToElement(img).perform();
WebElement signOut = driver.findElement(By.xpath("//a[contains(text(),'Sign Out')]"));
act.moveToElement(signOut).click().perform();

}
}

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class LinkedIn {
public static void main(String[] args) throws InterruptedException {
WebDriver driver=new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("https://www.linkedin.com/");
driver.findElement(By.id("session_key-login")).sendKeys("give_ur_userid_here");
driver.findElement(By.id("session_password-login")).sendKeys("give_ur_pass_here");
//driver.findElement(By.xpath("//input[@id='signin']")).click();
Actions act=new Actions(driver);
WebElement sign = driver.findElement(By.id("signin"));
act.moveToElement(sign).doubleClick().perform();
WebElement network = driver.findElement(By.xpath("//li[@class='nav-item']/a[contains(text(),'Connections')]"));
act.moveToElement(network).perform();
Thread.sleep(1000);
WebElement addConn = driver.findElement(By.xpath("//ul[@class='sub-nav']//a[contains(text(),'Add Connections')]"));
act.moveToElement(addConn).click().perform();
WebElement img = driver.findElement(By.xpath("//img[@class='img-defer nav-profile-photo']"));
act.moveToElement(img).perform();
WebElement signOut = driver.findElement(By.xpath("//a[contains(text(),'Sign Out')]"));
act.moveToElement(signOut).click().perform();

}
}

Friday, May 23, 2014

How to login in linkedIn

Note- After login, 1st move cursor over Connections then click on Add Connections.

import java.util.Scanner;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class LinkedIn {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("enter ur user id: ");
        String userId = in.nextLine();
        System.out.println("enter ur pass: ");
        String pass = in.nextLine();
     
        WebDriver driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.get("http://www.linkedin.com/?trk=nav_logo");
        //login
        driver.findElement(By.id("session_key-login")).sendKeys(userId);
        driver.findElement(By.id("session_password-login")).sendKeys(pass);
        Actions act = new Actions(driver);
        WebElement sign = driver.findElement(By.id("signin"));
        act.moveToElement(sign).doubleClick().perform();
     
        //1st move cursor over Connections then click on Add Connections
      
        WebElement network = driver.findElement(By.xpath("//li[@class='nav-item']/a[contains(text(),'Connections')]"));
        act.moveToElement(network).perform();
        driver.findElement(By.xpath("//ul[@class='sub-nav']//a[contains(text(),'Add Connections')]")).click();
      
        //signout
        WebElement img = driver.findElement(By.xpath("//img[@class='img-defer nav-profile-photo']"));
        act.moveToElement(img).perform();
        WebElement signOut = driver.findElement(By.xpath("//a[contains(text(),'Sign Out')]"));
        act.moveToElement(signOut).click().perform();
      
        driver.quit();
    }
}