Search in sources :

Example 6 with PhantomJSDriver

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
        }
    }
}
Also used : PhantomJSDriver(org.openqa.selenium.phantomjs.PhantomJSDriver) JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) WebElement(org.openqa.selenium.WebElement) VerificationException(com.axway.ats.uiengine.exceptions.VerificationException) NoAlertPresentException(org.openqa.selenium.NoAlertPresentException)

Example 7 with PhantomJSDriver

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);
}
Also used : PhantomJSDriver(org.openqa.selenium.phantomjs.PhantomJSDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities)

Example 8 with PhantomJSDriver

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);
}
Also used : PhantomJSDriver(org.openqa.selenium.phantomjs.PhantomJSDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities)

Example 9 with PhantomJSDriver

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.");
        }
    }
}
Also used : Rectangle(java.awt.Rectangle) OutputType(org.openqa.selenium.OutputType) UnreachableBrowserException(org.openqa.selenium.remote.UnreachableBrowserException) WebDriver(org.openqa.selenium.WebDriver) Proxy(org.openqa.selenium.Proxy) LoggerFactory(org.slf4j.LoggerFactory) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) TakesScreenshot(org.openqa.selenium.TakesScreenshot) ImageIO(javax.imageio.ImageIO) Dimension(org.openqa.selenium.Dimension) PhantomJSDriver(org.openqa.selenium.phantomjs.PhantomJSDriver) ImageReader(javax.imageio.ImageReader) Proxies(org.openqa.selenium.browserlaunchers.Proxies) CommandLine(org.openqa.selenium.os.CommandLine) Builder(org.openqa.selenium.phantomjs.PhantomJSDriverService.Builder) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) BufferedImage(java.awt.image.BufferedImage) Collection(java.util.Collection) By(org.openqa.selenium.By) IOException(java.io.IOException) Capabilities(org.openqa.selenium.Capabilities) FileInputStream(java.io.FileInputStream) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) File(java.io.File) ImageInputStream(javax.imageio.stream.ImageInputStream) ImageReadParam(javax.imageio.ImageReadParam) ComponentUtil(org.codelibs.fess.util.ComponentUtil) SessionNotFoundException(org.openqa.selenium.remote.SessionNotFoundException) PostConstruct(javax.annotation.PostConstruct) PhantomJSDriverService(org.openqa.selenium.phantomjs.PhantomJSDriverService) PhantomJSDriver(org.openqa.selenium.phantomjs.PhantomJSDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) Dimension(org.openqa.selenium.Dimension) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) UnreachableBrowserException(org.openqa.selenium.remote.UnreachableBrowserException) IOException(java.io.IOException) SessionNotFoundException(org.openqa.selenium.remote.SessionNotFoundException)

Aggregations

PhantomJSDriver (org.openqa.selenium.phantomjs.PhantomJSDriver)9 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)4 WebDriver (org.openqa.selenium.WebDriver)3 WebElement (org.openqa.selenium.WebElement)3 IOException (java.io.IOException)2 URL (java.net.URL)2 Test (org.junit.Test)2 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)2 PublicAtsApi (com.axway.ats.common.PublicAtsApi)1 VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)1 RealHtmlElementState (com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState)1 HttpRequestCallback (ghostdriver.server.HttpRequestCallback)1 Rectangle (java.awt.Rectangle)1 BufferedImage (java.awt.image.BufferedImage)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileReader (java.io.FileReader)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1