-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathBingSearchSteps.java
More file actions
66 lines (58 loc) · 2.13 KB
/
BingSearchSteps.java
File metadata and controls
66 lines (58 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package Steps;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.openqa.selenium.WebElement;
import Runner.TestRunner;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import java.util.concurrent.TimeUnit;
public class BingSearchSteps extends TestRunner
{
public RemoteWebDriver driver = this.connection;
public static String test_url = "https://www.bing.com";
WebDriverWait wait = new WebDriverWait(driver, 10);
@Given("^that I am on the Bing app$")
public void that_I_am_on_the_Bing_app()
{
System.out.println(driver.getCapabilities());
driver.navigate().to(test_url);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//wait.until((ExpectedCondition<Boolean>) wd ->
// ((JavascriptExecutor) wd).executeScript("return document.readyState").equals("complete"));
}
@When("^search for LambdaTest$")
public void click_on_the_text_box()
{
WebElement searchBox = driver.findElement(By.xpath("//textarea[@id='sb_form_q']"));
searchBox.sendKeys("HyperExecute");
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
searchBox.sendKeys(Keys.ENTER);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Then("^click on the first result$")
public void click_on_the_first_result()
{
WebElement secondCheckBox = driver.findElement(By.xpath("//a[contains(normalize-space(),'HyperExecute - AI-Powered Blazing Fast')]"));
secondCheckBox.click();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}