0% found this document useful (0 votes)
44 views

Code

The document shows code for opening the Chrome browser and interacting with elements on the Facebook login page. It imports Selenium WebDriver classes, initializes the ChromeDriver, navigates to Facebook, and finds elements to enter an email, password, and click the login button.

Uploaded by

SuprinAhluwalia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Code

The document shows code for opening the Chrome browser and interacting with elements on the Facebook login page. It imports Selenium WebDriver classes, initializes the ChromeDriver, navigates to Facebook, and finds elements to enter an email, password, and click the login button.

Uploaded by

SuprinAhluwalia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.util.

List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class chromebrowser {

public static void main(String[] args) {


// TODO Auto-generated method stub

//chromedriver.exe
System.setProperty("webdriver.chrome.driver", "C://work//chromedriver.exe");

WebDriver driver =new ChromeDriver();


driver.get("http://facebook.com"); //URL in the browser
//driver.findElement(By.className("inputtext")).sendKeys("helloworld");
/*driver.findElement(By.id("email")).sendKeys("Thisis my first code");
driver.findElement(By.name("pass")).sendKeys("123456");
driver.findElement(By.linkText("Forgot account?")).click();*/

driver.findElement(By.cssSelector("#email")).sendKeys("emailaddress");
driver.findElement(By.xpath("//*[@id='pass']")).sendKeys("password");
driver.findElement(By.xpath("//*[@id='login_form']/table/tbody/tr[3]/td[2]/div/
a")).click();

}
}

You might also like