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

ExplicitWait

The document is a Java code snippet that demonstrates the use of Selenium WebDriver for automating a Google account signup process. It includes methods for explicit waits to ensure elements are visible before interacting with them. The code sets up the ChromeDriver, navigates to the signup page, fills in user details, and clicks the 'Next' button.

Uploaded by

jadhavbs16
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

ExplicitWait

The document is a Java code snippet that demonstrates the use of Selenium WebDriver for automating a Google account signup process. It includes methods for explicit waits to ensure elements are visible before interacting with them. The code sets up the ChromeDriver, navigates to the signup page, fills in user details, and clicks the 'Next' button.

Uploaded by

jadhavbs16
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

package Demo_TNG;

import java.util.concurrent.TimeUnit;

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.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Test;

public class ExplicitWait {


@Test
public void f() {
System.setProperty("webdriver.chrome.driver","E:\\Eclipse Selenium\\
Downloads\\chrome_driver\\chromedriver.exe");
WebDriver dr = new ChromeDriver();
dr.manage().window().maximize();

dr.get("https://accounts.google.com/signup/v2/webcreateaccount?
flowName=GlifWebSignIn&flowEntry=SignUp");
//dr.get("");

//SendKeys

WebElement we= dr.findElement(By.xpath("//input[@id='firstName']"));


WebElement we1= dr.findElement(By.xpath("//input[@id='lastName']"));
WebElement we2=
dr.findElement(By.xpath("//body/div[1]/div[1]/div[2]/div[1]/div[2]/div[1]/div[1]/
div[2]/div[1]/div[1]/div[1]/form[1]/span[1]/section[1]/div[1]/div[1]/div[3]/
div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/input[1]"));
sendKeys(dr, we, 10, "Peter");
sendKeys(dr, we1, 5, "Mokashi");
sendKeys(dr, we2, 10, "12242343");

//Click

WebElement we3=
dr.findElement(By.xpath("//span[contains(text(),'Next')]"));
click(dr, we3, 10);
}

public static void sendKeys(WebDriver dr, WebElement element, int timeout,String


string) {

new WebDriverWait(dr, timeout).until(ExpectedConditions.visibilityOf(element));


element.sendKeys(string);
}
public static void click(WebDriver dr, WebElement element, int timeout) {
new WebDriverWait(dr,
timeout).until(ExpectedConditions.visibilityOf(element));
element.click();
}

You might also like