use of org.openqa.selenium.phantomjs.PhantomJSDriver in project ats-framework by Axway.
the class RealHtmlElementState method highlightElement.
private void highlightElement(boolean disregardConfiguration) {
if (webDriver instanceof PhantomJSDriver) {
// it is headless browser
return;
}
if (disregardConfiguration || UiEngineConfigurator.getInstance().getHighlightElements()) {
try {
WebElement webElement = RealHtmlElementLocator.findElement(element);
String styleAttrValue = webElement.getAttribute("style");
JavascriptExecutor js = (JavascriptExecutor) webDriver;
js.executeScript("arguments[0].setAttribute('style', arguments[1]);", webElement, // to change text use: "color: yellow; text-shadow: 0 0 2px #f00;"
"background-color: #ff9; border: 1px solid yellow; box-shadow: 0px 0px 10px #fa0;");
Thread.sleep(500);
js.executeScript("arguments[0].setAttribute('style', arguments[1]);", webElement, styleAttrValue);
} catch (Exception e) {
// swallow this error as highlighting is not critical
}
}
}
use of org.openqa.selenium.phantomjs.PhantomJSDriver in project Asqatasun by Asqatasun.
the class PhantomJsFactory method make.
/**
*
* @param config
* @return A FirefoxDriver.
*/
@Override
public RemoteWebDriver make(HashMap<String, String> config) {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
if (System.getProperty(PHANTOMJS_PATH_PROPERTY) != null) {
path = System.getProperty(PHANTOMJS_PATH_PROPERTY);
}
caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, path);
return new PhantomJSDriver(caps);
}
use of org.openqa.selenium.phantomjs.PhantomJSDriver in project geode by apache.
the class WebDriverRule method setUpWebDriver.
private void setUpWebDriver() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setJavascriptEnabled(true);
capabilities.setCapability("takesScreenshot", true);
capabilities.setCapability("phantomjs.page.settings.userAgent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:16.0) Gecko/20121026 Firefox/16.0");
driver = new PhantomJSDriver(capabilities);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(300, TimeUnit.SECONDS);
}
use of org.openqa.selenium.phantomjs.PhantomJSDriver in project fess by codelibs.
the class WebDriverGenerator method startWebDriver.
protected void startWebDriver() {
try {
if (webDriver == null) {
if (webDriverCapabilities == null) {
webDriver = new PhantomJSDriver();
} else {
if (webDriverCapabilities instanceof DesiredCapabilities) {
final DesiredCapabilities capabilities = (DesiredCapabilities) webDriverCapabilities;
webDriverCapabilities.asMap().entrySet().stream().filter(e -> e.getValue() instanceof String && filePathMap.containsKey(e.getValue().toString())).forEach(e -> capabilities.setCapability(e.getKey(), filePathMap.get(e.getValue().toString())));
}
webDriver = new PhantomJSDriver(createDriverService(webDriverCapabilities), webDriverCapabilities);
}
}
final FessConfig fessConfig = ComponentUtil.getFessConfig();
webDriver.manage().window().setSize(new Dimension(fessConfig.getThumbnailHtmlPhantomjsWindowWidthAsInteger(), fessConfig.getThumbnailHtmlPhantomjsWindowHeightAsInteger()));
previousCheckTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
} catch (final Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("WebDriver is not available for generating thumbnails.", e);
} else {
logger.info("WebDriver is not available for generating thumbnails.");
}
}
}
Aggregations