Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Locators

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 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