0% found this document useful (0 votes)
28 views3 pages

Locators

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

Locators

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

Webdriver methods

package org.yes;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Test {

public static void main(String[] args) {

System.setProperty("webdriver.chrome.driver",
"C:\\Users\\Laptop3\\eclipse-workspace\\Subash\\
driver\\chromedriver.exe");

//Launch the Browser


WebDriver driver = new ChromeDriver();

//Go to the URL


driver.get("https://en-gb.facebook.com/");

//to maximize the browser


driver.manage().window().maximize();

//to get the title of the Page


String pageTitle = driver.getTitle(); //ctrl +
2 release and press L
System.out.println(pageTitle);

//to get the current URL


String cur = driver.getCurrentUrl();
System.out.println(cur);

}
Locators

package org.yes;

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

public class Test {

public static void main(String[] args) {

System.setProperty("webdriver.chrome.driver",
"C:\\Users\\Laptop3\\eclipse-workspace\\Subash\\
driver\\chromedriver.exe");

//Launch the Browser


WebDriver driver = new ChromeDriver();

//Go to the URL


driver.get("https://en-gb.facebook.com/");

//Maximize the page


driver.manage().window().maximize();

//To inspect the element


WebElement txtUserName =
driver.findElement(By.id("email"));
//To insert the value
txtUserName.sendKeys("vgjgyug");

WebElement txtPassword =
driver.findElement(By.id("pass"));
txtPassword.sendKeys("twsr");

WebElement btnLogin =
driver.findElement(By.name("login"));
btnLogin.click();

You might also like