-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeAssign4.java
More file actions
75 lines (58 loc) · 2.02 KB
/
Copy pathHomeAssign4.java
File metadata and controls
75 lines (58 loc) · 2.02 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
67
68
69
70
71
72
73
74
75
package StepDefinition;
import static org.junit.Assert.assertEquals;
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
public class HomeAssign4 {
WebDriver driver;
String acttitle = null;
@Given("Open Google Application3")
public void open_google_application3() {
System.setProperty("webdriver.gecko.driver","D:\\jar files\\geckodriver.exe");
driver =new FirefoxDriver();
driver.get("https://www.google.com");
}
@When("Capture Title1")
public void capture_title1() {
acttitle =driver.getTitle();
System.out.println("Title of the page is "+acttitle);
}
@Then("I should get valid title as Google")
public void i_should_get_valid_title_as_google() {
String exctitle ="Google";
Assert.assertEquals(acttitle , exctitle);
driver.close();
}
@Given("Open Google Application4")
public void open_google_application4() {
System.setProperty("webdriver.gecko.driver","D:\\jar files\\geckodriver.exe");
driver =new FirefoxDriver();
driver.get("https://www.google.com");
System.out.println("In GIven");
}
@When("I search keyword and go for search1")
public void i_search_keyword_and_go_for_search1() {
driver.findElement(By.xpath("//input[@name='q']")).sendKeys("Cucumber",Keys.ENTER);
System.out.println("In When");
}
@Then("I should get valid search result1")
public void i_should_get_valid_search_result1() {
String exptext = "Cucumber";
String acttext= driver.getPageSource();
System.out.println(exptext);
if(acttext.contains(exptext))
{
System.out.println("TestCase Passes");
}
else
{
System.out.println("TestCase Fails");
}
System.out.println("In Then");
}
}