-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathManyToolsForm.java
More file actions
41 lines (34 loc) · 1.46 KB
/
ManyToolsForm.java
File metadata and controls
41 lines (34 loc) · 1.46 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
package manytools;
import aquality.selenium.browser.AqualityServices;
import aquality.selenium.core.utilities.IActionRetrier;
import aquality.selenium.elements.interfaces.IButton;
import aquality.selenium.elements.interfaces.ILabel;
import aquality.selenium.forms.Form;
import org.openqa.selenium.By;
import org.openqa.selenium.TimeoutException;
import java.util.Collections;
public abstract class ManyToolsForm<T extends ManyToolsForm<T>> extends Form {
private static final String BASE_URL = "https://manytools.org/";
private final ILabel lblValue = getFormLabel().findChildElement(By.xpath(".//code"), getName(), ILabel.class);
private final IButton btnAgree = getElementFactory().getButton(By.xpath("//button[@mode='primary']"), "Agree");
protected ManyToolsForm(String name) {
super(By.id("maincontent"), name);
}
protected abstract String getUrlPart();
@SuppressWarnings("unchecked")
public T open() {
AqualityServices.get(IActionRetrier.class).doWithRetry(() -> {
AqualityServices.getBrowser().goTo(BASE_URL + getUrlPart());
AqualityServices.getBrowser().waitForPageToLoad();
if (btnAgree.state().isDisplayed())
{
btnAgree.click();
btnAgree.state().waitForNotDisplayed();
}
}, Collections.singletonList(TimeoutException.class));
return (T) this;
}
public String getValue() {
return lblValue.getText();
}
}