-
Notifications
You must be signed in to change notification settings - Fork 129
Expand file tree
/
Copy pathGuineaPigPage.java
More file actions
60 lines (45 loc) · 1.54 KB
/
GuineaPigPage.java
File metadata and controls
60 lines (45 loc) · 1.54 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
package com.yourcompany.Pages;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class GuineaPigPage {
@FindBy(linkText = "i am a link")
private WebElement theActiveLink;
@FindBy(id = "your_comments")
private WebElement yourCommentsSpan;
@FindBy(id = "comments")
private WebElement commentsTextAreaInput;
@FindBy(id = "submit")
private WebElement submitButton;
public WebDriver driver;
public static String url = "https://saucelabs-sample-test-frameworks.github.io/training-test-page";
public static GuineaPigPage visitPage(WebDriver driver) {
GuineaPigPage page = new GuineaPigPage(driver);
page.visitPage();
return page;
}
public GuineaPigPage(WebDriver driver) {
this.driver = driver;
PageFactory.initElements(driver, this);
}
public void visitPage() {
this.driver.get(url);
}
public void followLink() {
theActiveLink.click();
}
public void submitComment(String text) {
commentsTextAreaInput.sendKeys(text);
submitButton.click();
}
public String getSubmittedCommentText() {
return yourCommentsSpan.getText();
}
public boolean isOnPage() {
String title = "I am a page title - Sauce Labs";
return driver.getTitle() == title;
}
}