-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathDeveloperGuidePage.java
More file actions
59 lines (48 loc) · 1.91 KB
/
DeveloperGuidePage.java
File metadata and controls
59 lines (48 loc) · 1.91 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
package angularjs.pages;
import com.frameworkium.core.ui.annotations.Visible;
import com.frameworkium.core.ui.pages.BasePage;
import io.qameta.allure.Step;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.ExpectedConditions;
import com.frameworkium.core.htmlelements.element.Link;
import com.frameworkium.core.htmlelements.element.TextInput;
import java.time.Duration;
public class DeveloperGuidePage extends BasePage<DeveloperGuidePage> {
@Visible
@FindBy(css = "input[name='as_q']")
private TextInput searchField;
@Visible
@FindBy(linkText = "Bootstrap")
private Link bootstrapSearchItem;
@FindBy(css = ".main-grid h1")
private WebElement guideTitle;
@Step("Click search bar")
public DeveloperGuidePage clickSearchBar() {
searchField.click();
return this;
}
@Step("Set search bar query text to {0}")
public DeveloperGuidePage setSearchBar(String inputText) {
searchField.sendKeys(inputText);
return this;
}
@Step("Click link from search results with title {0}")
public DeveloperGuidePage clickLinkWithTitle(String linkTitle) {
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(30));
var searchResultsLink = driver.findElement(
By.xpath(String.format(
"//nav[@id='navbar-main']//a[text()='%s']",
linkTitle)));
wait.until(ExpectedConditions.visibilityOf(searchResultsLink));
searchResultsLink.click();
return this;
}
@Step("Get developer guide article title")
public String getGuideTitle(String expectedText) {
// required to ensure test is more robust i.e. this can't return ""
wait.until(ExpectedConditions.textToBePresentInElement(guideTitle, expectedText));
return guideTitle.getText();
}
}