use of org.openqa.selenium.ScriptTimeoutException in project carina by qaprosoft.
the class DriverHelper method refresh.
/**
* Refresh browser.
*
* @param timeout long
*/
public void refresh(long timeout) {
WebDriver drv = getDriver();
Wait<WebDriver> wait = new FluentWait<WebDriver>(drv).pollingEvery(// there is no sense to refresh url address too often
Duration.ofMillis(5000)).withTimeout(Duration.ofSeconds(timeout)).ignoring(WebDriverException.class).ignoring(// org.openqa.selenium.json.JsonException: Expected to read a START_MAP but instead have: END. Last 0 characters read
JsonException.class);
try {
wait.until(new Function<WebDriver, Void>() {
public Void apply(WebDriver driver) {
drv.navigate().refresh();
return null;
}
});
} catch (ScriptTimeoutException | TimeoutException e) {
Messager.FAIL_REFRESH.error();
}
Messager.REFRESH.info();
}
use of org.openqa.selenium.ScriptTimeoutException in project carina by qaprosoft.
the class DriverHelper method getPageSource.
/*
* Get and return the source of the last loaded page.
* @return String
*/
public String getPageSource() {
WebDriver drv = getDriver();
Messager.GET_PAGE_SOURCE.info();
Wait<WebDriver> wait = new FluentWait<WebDriver>(drv).pollingEvery(// there is no sense to refresh url address too often
Duration.ofMillis(5000)).withTimeout(Duration.ofSeconds(Configuration.getInt(Parameter.EXPLICIT_TIMEOUT))).ignoring(WebDriverException.class).ignoring(// org.openqa.selenium.JavascriptException: javascript error: Cannot read property 'outerHTML' of null
JavascriptException.class);
String res = "";
try {
res = wait.until(new Function<WebDriver, String>() {
public String apply(WebDriver driver) {
return drv.getPageSource();
}
});
} catch (ScriptTimeoutException | TimeoutException e) {
Messager.FAIL_GET_PAGE_SOURCE.error();
}
Messager.GET_PAGE_SOURCE.info();
return res;
}
use of org.openqa.selenium.ScriptTimeoutException in project carina by qaprosoft.
the class DriverHelper method getTitle.
/**
* Return page title.
*
* @param timeout long
* @return title String.
*/
public String getTitle(long timeout) {
WebDriver drv = getDriver();
Wait<WebDriver> wait = new FluentWait<WebDriver>(drv).pollingEvery(Duration.ofMillis(RETRY_TIME)).withTimeout(Duration.ofSeconds(timeout)).ignoring(WebDriverException.class).ignoring(// org.openqa.selenium.JavascriptException: javascript error: Cannot read property 'outerHTML' of null
JavascriptException.class);
String res = "";
try {
res = wait.until(new Function<WebDriver, String>() {
public String apply(WebDriver driver) {
return drv.getTitle();
}
});
} catch (ScriptTimeoutException | TimeoutException e) {
Messager.FAIL_GET_TITLE.error();
}
return res;
}
Aggregations