Search in sources :

Example 21 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project ephemerals by LivePersonInc.

the class SeleniumEphemeralTest method test.

@Test
public void test() {
    RemoteWebDriver remoteWebDriver = seleniumResource.get();
    remoteWebDriver.get("http://yahoo.com");
    Assert.assertNotNull(remoteWebDriver.findElementById("uh-logo"));
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) Test(org.junit.Test)

Example 22 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project carina by qaprosoft.

the class MobileFactory method create.

@Override
public WebDriver create(String name, Device device, DesiredCapabilities capabilities, String seleniumHost) {
    if (seleniumHost == null) {
        seleniumHost = Configuration.get(Configuration.Parameter.SELENIUM_HOST);
    }
    String driverType = Configuration.getDriverType();
    String mobilePlatformName = Configuration.getPlatform();
    // TODO: refactor code to be able to remove SpecialKeywords.CUSTOM property completely
    // use comparison for custom_capabilities here to localize as possible usage of CUSTOM attribute
    String customCapabilities = Configuration.get(Parameter.CUSTOM_CAPABILITIES);
    if (!customCapabilities.isEmpty()) {
        mobilePlatformName = SpecialKeywords.CUSTOM;
    }
    LOGGER.debug("selenium: " + seleniumHost);
    RemoteWebDriver driver = null;
    if (isCapabilitiesEmpty(capabilities)) {
        capabilities = getCapabilities(name, device);
    }
    try {
        if (driverType.equalsIgnoreCase(SpecialKeywords.MOBILE)) {
            if (mobilePlatformName.toLowerCase().equalsIgnoreCase(SpecialKeywords.ANDROID)) {
                driver = new AndroidDriver<AndroidElement>(new URL(seleniumHost), capabilities);
            } else if (mobilePlatformName.toLowerCase().equalsIgnoreCase(SpecialKeywords.IOS)) {
                driver = new IOSDriver<IOSElement>(new URL(seleniumHost), capabilities);
            } else if (mobilePlatformName.toLowerCase().equalsIgnoreCase(SpecialKeywords.CUSTOM)) {
                // that's a case for custom mobile capabilities like browserstack or saucelabs
                driver = new RemoteWebDriver(new URL(seleniumHost), capabilities);
            } else {
                throw new RuntimeException("Unsupported mobile capabilities for type: " + driverType + " platform: " + mobilePlatformName);
            }
        }
        if (device.isNull()) {
            // TODO: double check that local run with direct appium works fine
            RemoteDevice remoteDevice = getDeviceInfo(seleniumHost, driver.getSessionId().toString());
            // 3rd party solutions like browserstack or saucelabs return not null remoteDevice object. But inside nothing useful
            if (remoteDevice != null && remoteDevice.getName() != null) {
                device = new Device(remoteDevice);
            } else {
                device = new Device(driver.getCapabilities());
            }
            boolean stfEnabled = R.CONFIG.getBoolean(SpecialKeywords.CAPABILITIES + "." + SpecialKeywords.STF_ENABLED);
            if (stfEnabled) {
                device.connectRemote();
            }
            DevicePool.registerDevice(device);
        }
        // will be performed just in case uninstall_related_apps flag marked as true
        device.uninstallRelatedApps();
    } catch (MalformedURLException e) {
        LOGGER.error("Malformed selenium URL! " + e.getMessage(), e);
    }
    if (driver == null) {
        Assert.fail("Unable to initialize driver: " + name + "!");
    }
    return driver;
}
Also used : IOSDriver(io.appium.java_client.ios.IOSDriver) MalformedURLException(java.net.MalformedURLException) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) RemoteDevice(com.qaprosoft.carina.commons.models.RemoteDevice) Device(com.qaprosoft.carina.core.foundation.webdriver.device.Device) AndroidElement(io.appium.java_client.android.AndroidElement) RemoteDevice(com.qaprosoft.carina.commons.models.RemoteDevice) URL(java.net.URL)

Example 23 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project carina by qaprosoft.

the class ExtendedWebElement method getElementInfo.

@SuppressWarnings("unchecked")
private ElementInfo getElementInfo(ExtendedWebElement extendedWebElement) {
    ElementInfo elementInfo = new ElementInfo();
    if (extendedWebElement.isElementPresent(1)) {
        Point location = extendedWebElement.getElement().getLocation();
        Dimension size = extendedWebElement.getElement().getSize();
        elementInfo.setRect(new Rect(location.getX(), location.getY(), size.getWidth(), size.getHeight()));
        elementInfo.setElementsAttributes((Map<String, String>) ((RemoteWebDriver) driver).executeScript(ATTRIBUTE_JS, extendedWebElement.getElement()));
        try {
            elementInfo.setText(extendedWebElement.getText());
        } catch (Exception e) {
            elementInfo.setText("");
        }
        return elementInfo;
    } else {
        return null;
    }
}
Also used : Rect(com.qaprosoft.carina.core.foundation.utils.metadata.model.Rect) ElementInfo(com.qaprosoft.carina.core.foundation.utils.metadata.model.ElementInfo) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Example 24 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project vertx-openshift-it by cescoffier.

the class PhantomJSDeployment method connectToWebService.

public WebDriver connectToWebService() {
    DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
    driver = new RemoteWebDriver(getUrl(), capabilities);
    driver.manage().window().setSize(new Dimension(1920, 1080));
    return driver;
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) Dimension(org.openqa.selenium.Dimension)

Example 25 with RemoteWebDriver

use of org.openqa.selenium.remote.RemoteWebDriver in project testcontainers-java by testcontainers.

the class FlakyContainerCreationTest method testCreationOfManyContainers.

@Test
@Ignore
public void testCreationOfManyContainers() {
    for (int i = 0; i < 50; i++) {
        BrowserWebDriverContainer container = new BrowserWebDriverContainer().withDesiredCapabilities(DesiredCapabilities.chrome()).withRecordingMode(BrowserWebDriverContainer.VncRecordingMode.RECORD_FAILING, new File("build"));
        container.start();
        RemoteWebDriver driver = container.getWebDriver();
        driver.get("http://www.google.com");
        container.stop();
    }
}
Also used : BrowserWebDriverContainer(org.testcontainers.containers.BrowserWebDriverContainer) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)101 URL (java.net.URL)39 Test (org.junit.Test)36 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)29 File (java.io.File)16 WebDriver (org.openqa.selenium.WebDriver)14 MalformedURLException (java.net.MalformedURLException)13 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)13 ChromeOptions (org.openqa.selenium.chrome.ChromeOptions)12 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)12 IOException (java.io.IOException)11 Dimension (org.openqa.selenium.Dimension)9 InternetExplorerDriver (org.openqa.selenium.ie.InternetExplorerDriver)7 PhantomJSDriver (org.openqa.selenium.phantomjs.PhantomJSDriver)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 FirefoxProfile (org.openqa.selenium.firefox.FirefoxProfile)6 EventFiringWebDriver (org.openqa.selenium.support.events.EventFiringWebDriver)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 Before (org.junit.Before)5