0% found this document useful (0 votes)
52 views1 page

Code 2

This Java code uses Selenium WebDriver to automate the login process on Facebook. It sets up the ChromeDriver, navigates to the Facebook website, and demonstrates how to locate elements using both XPath and CSS selectors. The commented-out code shows an alternative method for inputting email and password using XPath, while the active code uses CSS selectors for the same purpose.

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)
52 views1 page

Code 2

This Java code uses Selenium WebDriver to automate the login process on Facebook. It sets up the ChromeDriver, navigates to the Facebook website, and demonstrates how to locate elements using both XPath and CSS selectors. The commented-out code shows an alternative method for inputting email and password using XPath, while the active code uses CSS selectors for the same purpose.

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 org.openqa.selenium.

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

public class facebookxpath {

public static void main(String[] args) {


// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver",
"C://work//chromedriver.exe");

WebDriver driver =new ChromeDriver();


driver.get("http://facebook.com");

////tagName[@attribute='value'] - xpath
/* driver.findElement(By.xpath("//*[@type='email']")).sendKeys("myown
xpath");
driver.findElement(By.xpath("//input[@id='pass']")).sendKeys("hello");
driver.findElement(By.xpath("//input[@value='Log In']")).click();*/

//tagName[v='value'] -CSS

driver.findElement(By.cssSelector("input[name='email']")).sendKeys("myowncss");
driver.findElement(By.cssSelector("[value='Log In']")).click();

You might also like