Skip to content

Instantly share code, notes, and snippets.

@muditlambda
Created August 10, 2021 09:51
package stepDefinitions;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
public class SingleOne {
WebDriver driver;
@Given("Google is open in the browser")
public void google_is_open_in_the_browser() {
System.setProperty("webdriver.chrome.driver", "D:\\Gunjan\\Selenium\\chromedriver.exe");
driver = new ChromeDriver();
System.out.format("Thread ID - %2d - from feature file single.\n",
Thread.currentThread().getId());
driver.get("https://www.google.com/");
driver.manage().window().maximize();
}
@When("User searches for Lambda Test")
public void user_searches_for_lambda_test() {
driver.findElement(By.xpath("//input[@name='q']")).sendKeys("Lambda Test");
driver.findElement(By.xpath("//div[@class='FPdoLc lJ9FBc']//input[@name='btnK']")).click();
}
@When("User searches for Selenium cross browser testing")
public void user_searches_for_Selenium_cross_browser_testing(){
driver.findElement(By.xpath("//input[@name='q']")).sendKeys("Selenium Cross Browser Testing");
driver.findElement(By.xpath("//div[@class='FPdoLc lJ9FBc']//input[@name='btnK']")).click();
}
@Then("Results are displayed")
public void results_are_displayed() {
System.out.println("The page title is - " +driver.getTitle());
driver.quit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment