-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathSamplePOSteps.java
More file actions
56 lines (45 loc) · 1.64 KB
/
Copy pathSamplePOSteps.java
File metadata and controls
56 lines (45 loc) · 1.64 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
package stepDefinitions;
import io.cucumber.java.en.And;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.PageFactory;
import pages_sample.*;
import java.util.Map;
import static org.junit.Assert.assertEquals;
public class SamplePOSteps {
private WebDriver driver;
static AgePage agePage;
static AgeSubmittedPage ageSubmittedPage;
public SamplePOSteps() {
this.driver = Hooks.driver;
agePage = PageFactory.initElements(Hooks.driver, AgePage.class);
ageSubmittedPage = PageFactory.initElements(Hooks.driver, AgeSubmittedPage.class);
}
@When("^I enter name: \"([^\"]*)\" using PO$")
public void iEnterName(String name) throws Throwable {
agePage.enterName(name);
}
@And("^I enter age: (\\d+) using PO$")
public void iEnterAge(int age) throws Throwable {
agePage.enterAge(age);
}
@Given("^I (?:am on|open) age page using PO$")
public void iAmOnAgePage() throws Throwable {
driver.get(agePage.getPageUrl());
}
@And("^I click submit age using PO$")
public void iClickSubmitAge() throws Throwable {
agePage.clickSubmit();
}
@Then("^I see message: \"(.*)\" using PO$")
public void iSeeMessage(String message) throws Throwable {
ageSubmittedPage.checkMessageText(message);
}
@When("^I enter values using PO:$")
public void iEnterValues(Map<String, String> valuesToEnter) throws Throwable {
agePage.enterName(valuesToEnter.get("name"));
agePage.enterAge(valuesToEnter.get("age"));
}
}