use of org.openqa.selenium.JavascriptExecutor in project selenium-tests by Wikia.
the class VisualEditModePageObject method triggerCategorySuggestions.
public void triggerCategorySuggestions() {
int timeout = 0;
pressDownArrow(categoryInput);
JavascriptExecutor js = (JavascriptExecutor) driver;
String returned = (String) js.executeScript("return $('ul.ui-autocomplete li').text()");
while (returned.isEmpty() && timeout <= 5000) {
try {
Thread.sleep(500);
timeout += 500;
} catch (InterruptedException e) {
PageObjectLogging.log("triggerCategorySuggestions", "Interrupted Exception occurred", false);
}
pressDownArrow(categoryInput);
returned = (String) js.executeScript("return $('ul.ui-autocomplete li').text()");
}
}
use of org.openqa.selenium.JavascriptExecutor in project selenium-tests by Wikia.
the class TableOfContentPageObject method isH2PaddingTopMoreThan.
public boolean isH2PaddingTopMoreThan(int index, int value) {
JavascriptExecutor js = (JavascriptExecutor) driver;
String h2PaddingString = js.executeScript("return $('h2').eq(" + index + ").css('padding-top')").toString();
h2PaddingString = h2PaddingString.substring(0, h2PaddingString.length() - 2);
int h2Padding = Integer.parseInt(h2PaddingString);
return h2Padding >= value;
}
use of org.openqa.selenium.JavascriptExecutor in project selenium-tests by Wikia.
the class ArticlePageObject method triggerEditCommentArea.
public MiniEditorComponentObject triggerEditCommentArea() {
jsActions.scrollToElement(allCommentsArea);
WebElement mostRecentComment = articleComments.get(0);
PageObjectLogging.log("First check", mostRecentComment.getText(), true);
JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement editButton = mostRecentComment.findElement(By.cssSelector(EDIT_BUTTON_SELECTOR));
new Actions(driver).moveToElement(editButton).perform();
js.executeScript("arguments[0].querySelector(arguments[1]).click()", mostRecentComment, EDIT_BUTTON_SELECTOR);
return new MiniEditorComponentObject(driver);
}
use of org.openqa.selenium.JavascriptExecutor in project selenium-tests by Wikia.
the class AdsBaseObject method hideElementIfPresent.
protected void hideElementIfPresent(String cssSelector) {
if (isElementOnPage(By.cssSelector(cssSelector))) {
PageObjectLogging.log("Hiding element", cssSelector, true);
WebElement element = driver.findElement(By.cssSelector(cssSelector));
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("$(arguments[0]).css('display', 'none')", element);
waitForElementNotVisibleByElement(element);
}
}
use of org.openqa.selenium.JavascriptExecutor in project fess by codelibs.
the class WebDriverGenerator method generate.
@Override
public boolean generate(final String thumbnailId, final String url, final File outputFile) {
if (logger.isDebugEnabled()) {
logger.debug("Generate Thumbnail: " + url);
}
if (outputFile.exists()) {
if (logger.isDebugEnabled()) {
logger.debug("The thumbnail file exists: " + outputFile.getAbsolutePath());
}
return true;
}
final File parentFile = outputFile.getParentFile();
if (!parentFile.exists()) {
parentFile.mkdirs();
}
if (!parentFile.isDirectory()) {
logger.warn("Not found: " + parentFile.getAbsolutePath());
return false;
}
if (webDriver instanceof TakesScreenshot) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
synchronized (this) {
try {
webDriver.get(url);
if (webDriver instanceof JavascriptExecutor) {
final Dimension dim = webDriver.findElement(By.tagName("body")).getSize();
if (dim.height >= fessConfig.getThumbnailHtmlPhantomjsMaxHeightAsInteger()) {
if (logger.isInfoEnabled()) {
logger.info("Skpped Thumbnail generation " + dim + " for " + url);
}
return false;
}
}
final File thumbnail = ((TakesScreenshot) webDriver).getScreenshotAs(OutputType.FILE);
convert(thumbnail, outputFile);
updateThumbnailField(thumbnailId, url, url);
return true;
} catch (final UnreachableBrowserException | SessionNotFoundException e) {
if (logger.isDebugEnabled()) {
logger.debug("WebDriver is not available.", e);
}
previousCheckTime = 0;
} finally {
final long now = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
if (now - previousCheckTime > fessConfig.getThumbnailHtmlPhantomjsKeepAliveAsInteger().longValue()) {
destroy();
startWebDriver();
}
}
}
} else {
logger.warn("WebDriver is not instance of TakesScreenshot: " + webDriver);
}
return false;
}
Aggregations