Search in sources :

Example 36 with CustomEventFiringWebDriver

use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.

the class TestBrowserStackDriverFactory method testBrowserStack.

/**
 * For this test to run, you must add the following JVM parameters
 * -Dapp=<application.apk>
 * -DappPackage=<package>
 * -DappActivity=<activity>
 * -DappWaitActivity=<waitActivity> # if any
 * -DwebDriverGrid=https://<user>:<key>@hub.browserstack.com/wd/hub
 * -Dhttps.proxyHost=<proxy_host> -Dhttps.proxyPort=<proxy_port>
 */
@Test(groups = "no-test")
public void testBrowserStack() {
    SeleniumTestsContextManager.getThreadContext().setTestType(TestType.APPIUM_APP_ANDROID);
    SeleniumTestsContextManager.getThreadContext().setPlatform("android 11.0");
    SeleniumTestsContextManager.getThreadContext().setDeviceName("Google Pixel 4");
    SeleniumTestsContextManager.getThreadContext().setRunMode("browserstack");
    SeleniumTestsContextManager.getThreadContext().configureContext(Reporter.getCurrentTestResult());
    WebDriver driver = WebUIDriver.getWebDriver(true);
    WebDriver realDriver = ((CustomEventFiringWebDriver) driver).getWebDriver();
    driver.findElements(By.xpath("//*")).get(0).getText();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 37 with CustomEventFiringWebDriver

use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.

the class TestSauceLabsDriverFactory method testSauceLabs.

/**
 * For this test to run, you must add the following JVM parameters
 * -Dapp=<application.apk>
 * -DappPackage=<package>
 * -DappActivity=<activity>
 * -DappWaitActivity=<waitActivity> # if any
 * -DwebDriverGrid=https://<user>:<key>@ondemand.eu-central-1.saucelabs.com:443/wd/hub
 * -Dhttps.proxyHost=<proxy_host> -Dhttps.proxyPort=<proxy_port>
 */
@Test(groups = "no-test")
public void testSauceLabs() {
    SeleniumTestsContextManager.getThreadContext().setTestType(TestType.APPIUM_APP_ANDROID);
    SeleniumTestsContextManager.getThreadContext().setPlatform("android 11");
    SeleniumTestsContextManager.getThreadContext().setDeviceName(".*google.*");
    SeleniumTestsContextManager.getThreadContext().setRunMode("saucelabs");
    SeleniumTestsContextManager.getThreadContext().configureContext(Reporter.getCurrentTestResult());
    WebDriver driver = WebUIDriver.getWebDriver(true);
    WebDriver realDriver = ((CustomEventFiringWebDriver) driver).getWebDriver();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 38 with CustomEventFiringWebDriver

use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.

the class UiElement method getDriver.

public CustomEventFiringWebDriver getDriver() {
    WebUIDriver uiDriver = WebUIDriver.getWebUIDriver(false);
    if (uiDriver == null) {
        throw new ScenarioException("Driver has not already been created");
    }
    CustomEventFiringWebDriver driver = (CustomEventFiringWebDriver) uiDriver.getDriver();
    if (driver == null) {
        throw new ScenarioException("Driver has not already been created");
    }
    return driver;
}
Also used : WebUIDriver(com.seleniumtests.driver.WebUIDriver) CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) ScenarioException(com.seleniumtests.customexception.ScenarioException)

Example 39 with CustomEventFiringWebDriver

use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.

the class TestPageObject method testResizeWindow.

@Test(groups = { "it" })
public void testResizeWindow() throws Exception {
    SeleniumTestsContextManager.getThreadContext().setBrowser("*firefox");
    driver = WebUIDriver.getWebDriver(true);
    new DriverTestPage(true).resizeTo(600, 400);
    Dimension viewPortSize = ((CustomEventFiringWebDriver) driver).getViewPortDimensionWithoutScrollbar();
    Assert.assertEquals(viewPortSize.width, 600);
    Assert.assertEquals(viewPortSize.height, 400);
}
Also used : DriverTestPage(com.seleniumtests.it.driver.support.pages.DriverTestPage) CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) Dimension(org.openqa.selenium.Dimension) GenericDriverTest(com.seleniumtests.GenericDriverTest) Test(org.testng.annotations.Test)

Example 40 with CustomEventFiringWebDriver

use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.

the class PageObject method resizeTo.

/**
 * Resize window to given dimensions.
 *
 * @param  width
 * @param  height
 */
public final void resizeTo(final int width, final int height) {
    // app test are not compatible with window
    if (SeleniumTestsContextManager.isAppTest()) {
        return;
    }
    try {
        Dimension setSize = new Dimension(width, height);
        driver.manage().window().setPosition(new Point(0, 0));
        int retries = 5;
        for (int i = 0; i < retries; i++) {
            driver.manage().window().setSize(setSize);
            Dimension viewPortSize = ((CustomEventFiringWebDriver) driver).getViewPortDimensionWithoutScrollbar();
            if (viewPortSize.height == height && viewPortSize.width == width) {
                break;
            } else {
                setSize = new Dimension(2 * width - viewPortSize.width, 2 * height - viewPortSize.height);
            }
        }
    } catch (Exception ex) {
        internalLogger.error(ex);
    }
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) Dimension(org.openqa.selenium.Dimension) Point(org.openqa.selenium.Point) Point(org.openqa.selenium.Point) ScenarioException(com.seleniumtests.customexception.ScenarioException) InvocationTargetException(java.lang.reflect.InvocationTargetException) CustomSeleniumTestsException(com.seleniumtests.customexception.CustomSeleniumTestsException) TimeoutException(org.openqa.selenium.TimeoutException) NotCurrentPageException(com.seleniumtests.customexception.NotCurrentPageException) UnreachableBrowserException(org.openqa.selenium.remote.UnreachableBrowserException) WebDriverException(org.openqa.selenium.WebDriverException) UnhandledAlertException(org.openqa.selenium.UnhandledAlertException) ConfigurationException(com.seleniumtests.customexception.ConfigurationException) NoAlertPresentException(org.openqa.selenium.NoAlertPresentException) IOException(java.io.IOException) UnsupportedCommandException(org.openqa.selenium.UnsupportedCommandException) NoSuchWindowException(org.openqa.selenium.NoSuchWindowException)

Aggregations

CustomEventFiringWebDriver (com.seleniumtests.driver.CustomEventFiringWebDriver)77 Test (org.testng.annotations.Test)53 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)36 MockitoTest (com.seleniumtests.MockitoTest)35 Dimension (org.openqa.selenium.Dimension)26 WebDriver (org.openqa.selenium.WebDriver)14 GenericDriverTest (com.seleniumtests.GenericDriverTest)12 Point (org.openqa.selenium.Point)12 GenericTest (com.seleniumtests.GenericTest)10 ScenarioException (com.seleniumtests.customexception.ScenarioException)9 WebDriverException (org.openqa.selenium.WebDriverException)7 BeforeMethod (org.testng.annotations.BeforeMethod)7 DriverExceptionListener (com.seleniumtests.driver.DriverExceptionListener)6 SkipException (org.testng.SkipException)6 NLWebDriver (com.neotys.selenium.proxies.NLWebDriver)5 File (java.io.File)5 IOException (java.io.IOException)5 Rectangle (org.openqa.selenium.Rectangle)5 WebElement (org.openqa.selenium.WebElement)5 BrowserInfo (com.seleniumtests.browserfactory.BrowserInfo)4