Search in sources :

Example 1 with DriverTestPage

use of com.seleniumtests.it.driver.support.pages.DriverTestPage in project seleniumRobot by bhecquet.

the class TestLogActions method testVideoStartDateSetWhenVideoRecordingDisabled.

@Test(groups = { "it" })
public void testVideoStartDateSetWhenVideoRecordingDisabled() throws Exception {
    WebDriver driver = null;
    try {
        SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
        SeleniumTestsContextManager.getThreadContext().setVideoCapture("false");
        driver = WebUIDriver.getWebDriver(true);
        DriverTestPage testPage = new DriverTestPage(true);
        WaitHelper.waitForSeconds(1);
        testPage._writeSomething();
        TestStepManager stepManager = SeleniumTestsContextManager.getThreadContext().getTestStepManager();
        TestStep step = stepManager.getTestSteps().get(2);
        Assert.assertEquals(step.getVideoTimeStamp(), 0);
        Assert.assertNull(stepManager.getVideoStartDate());
    } finally {
        if (driver != null) {
            WebUIDriver.cleanUp();
        }
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) TestStep(com.seleniumtests.reporter.logger.TestStep) DriverTestPage(com.seleniumtests.it.driver.support.pages.DriverTestPage) TestStepManager(com.seleniumtests.core.TestStepManager) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 2 with DriverTestPage

use of com.seleniumtests.it.driver.support.pages.DriverTestPage in project seleniumRobot by bhecquet.

the class TestLogActions method testVideoStartDateSetWhenVideoRecordingEnabled.

@Test(groups = { "it" })
public void testVideoStartDateSetWhenVideoRecordingEnabled() throws Exception {
    WebDriver driver = null;
    try {
        SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
        SeleniumTestsContextManager.getThreadContext().setVideoCapture("true");
        driver = WebUIDriver.getWebDriver(true);
        DriverTestPage testPage = new DriverTestPage(true);
        WaitHelper.waitForSeconds(1);
        testPage._writeSomething();
        TestStepManager stepManager = SeleniumTestsContextManager.getThreadContext().getTestStepManager();
        TestStep step = stepManager.getTestSteps().get(2);
        Assert.assertTrue(step.getVideoTimeStamp() > 0);
        Assert.assertNotNull(stepManager.getVideoStartDate());
    } finally {
        if (driver != null) {
            WebUIDriver.cleanUp();
        }
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) TestStep(com.seleniumtests.reporter.logger.TestStep) DriverTestPage(com.seleniumtests.it.driver.support.pages.DriverTestPage) TestStepManager(com.seleniumtests.core.TestStepManager) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 3 with DriverTestPage

use of com.seleniumtests.it.driver.support.pages.DriverTestPage in project seleniumRobot by bhecquet.

the class GenericMultiBrowserTest method exposeTestPage.

@BeforeClass(groups = { "it", "ut", "upload", "ie" })
public void exposeTestPage(final ITestContext testNGCtx) throws Exception {
    // skip following if driver is already defined from an other test
    if (driver != null) {
        return;
    }
    if (browserType == null || !installedBrowsers.contains(browserType)) {
        return;
    }
    localAddress = Inet4Address.getLocalHost().getHostAddress();
    // localAddress = Inet4Address.getByName("localhost").getHostAddress();
    server = new WebServer(localAddress, getPageMapping());
    server.expose();
    logger.info(String.format("exposing server on http://%s:%d", localAddress, server.getServerHost().getPort()));
    initThreadContext(testNGCtx);
    initBeforeMethod();
    try {
        switch(testPageName) {
            case "DriverTestPageWithoutFixedPattern":
                testPageUrl = String.format("http://%s:%d/testWithoutFixedPattern.html", localAddress, server.getServerHost().getPort());
                testPageWithoutPattern = new DriverTestPageWithoutFixedPattern(true, testPageUrl);
                break;
            case "DriverTestPage":
                testPageUrl = String.format("http://%s:%d/test.html", localAddress, server.getServerHost().getPort());
                testPage = new DriverTestPage(true, testPageUrl);
                break;
            case "DriverTestPageNativeActions":
                testPageUrl = String.format("http://%s:%d/test.html", localAddress, server.getServerHost().getPort());
                testPageNativeActions = new DriverTestPageNativeActions(true, testPageUrl);
                break;
            case "DriverTestPageObjectFactory":
                testPageUrl = String.format("http://%s:%d/test.html", localAddress, server.getServerHost().getPort());
                testPageObjectFactory = new DriverTestPageObjectFatory(true, testPageUrl);
                break;
            case "DriverTestAngularFrame":
                testPageUrl = String.format("http://%s:%d/testAngularIFrame.html", localAddress, server.getServerHost().getPort());
                angularFramePage = new DriverTestAngularFrame(true, testPageUrl);
                break;
            case "DriverSubAngularTestPage":
                testPageUrl = String.format("http://%s:%d/angularApp/index.html", localAddress, server.getServerHost().getPort());
                angularPage = new DriverSubAngularTestPage(true, testPageUrl);
                break;
            case "DriverScrollingTestPage":
                testPageUrl = String.format("http://%s:%d/testScrolling.html", localAddress, server.getServerHost().getPort());
                scrollingTestPage = new DriverScrollingTestPage(true, testPageUrl);
                break;
            case "DriverTestPageSalesforceLightning":
                lightningPage = new DriverTestPageSalesforceLightning();
                break;
        }
    } catch (Exception e) {
        logger.error("Error opening page");
        logger.error(WebUIDriver.getWebDriver(true).getPageSource());
        throw e;
    }
    driver = WebUIDriver.getWebDriver(true);
}
Also used : DriverTestPageNativeActions(com.seleniumtests.it.driver.support.pages.DriverTestPageNativeActions) DriverTestPageObjectFatory(com.seleniumtests.it.driver.support.pages.DriverTestPageObjectFatory) DriverSubAngularTestPage(com.seleniumtests.it.driver.support.pages.DriverSubAngularTestPage) DriverTestAngularFrame(com.seleniumtests.it.driver.support.pages.DriverTestAngularFrame) DriverTestPageSalesforceLightning(com.seleniumtests.it.driver.support.pages.DriverTestPageSalesforceLightning) DriverTestPage(com.seleniumtests.it.driver.support.pages.DriverTestPage) DriverTestPageWithoutFixedPattern(com.seleniumtests.it.driver.support.pages.DriverTestPageWithoutFixedPattern) WebServer(com.seleniumtests.it.driver.support.server.WebServer) DriverScrollingTestPage(com.seleniumtests.it.driver.support.pages.DriverScrollingTestPage) SkipException(org.testng.SkipException) WebDriverException(org.openqa.selenium.WebDriverException) IOException(java.io.IOException) AWTException(java.awt.AWTException) BeforeClass(org.testng.annotations.BeforeClass)

Example 4 with DriverTestPage

use of com.seleniumtests.it.driver.support.pages.DriverTestPage in project seleniumRobot by bhecquet.

the class TestDriver method testCaptureWhenWindowIsClosed.

/**
 * @throws Exception
 */
public void testCaptureWhenWindowIsClosed() throws Exception {
    DriverTestPage page = new DriverTestPage();
    page._goToNewPage();
    // close window
    DriverSubTestPage.closeButton.click();
    Alert alert = page.waitForAlert(3);
    if (alert != null) {
        alert.accept();
    }
    try {
        driver.getCurrentUrl();
    } catch (NoSuchWindowException e) {
    }
    Assert.assertNotNull(WebUIDriver.getWebDriver(false));
}
Also used : DriverTestPage(com.seleniumtests.it.driver.support.pages.DriverTestPage) Alert(org.openqa.selenium.Alert) NoSuchWindowException(org.openqa.selenium.NoSuchWindowException)

Example 5 with DriverTestPage

use of com.seleniumtests.it.driver.support.pages.DriverTestPage in project seleniumRobot by bhecquet.

the class TestPageObject method testPageObjectForExternalDriver.

/**
 * issue #324: check handles are not null. We cannot directly reproduce problem because we should have a test site which creates a second window when opened
 * @throws Exception
 */
@Test(groups = { "it", "pageobject" })
public void testPageObjectForExternalDriver() throws Exception {
    try {
        SeleniumTestsContextManager.getThreadContext().setTestType(TestType.WEB);
        Map<BrowserType, List<BrowserInfo>> browsers = OSUtility.getInstalledBrowsersWithVersion();
        String path = browsers.get(BrowserType.CHROME).get(0).getPath();
        int port = GenericDriverTest.findFreePort();
        // create chrome browser with the right option
        OSCommand.executeCommand(new String[] { path, "--remote-debugging-port=" + port, "about:blank" });
        DriverTestPage secondPage = new DriverTestPage(BrowserType.CHROME, port);
        Assert.assertNotNull(secondPage.getCurrentHandles());
    } finally {
        // switch back to main driver to avoid annoying other tests
        testPage.switchToDriver("main");
    }
}
Also used : DriverTestPage(com.seleniumtests.it.driver.support.pages.DriverTestPage) BrowserType(com.seleniumtests.driver.BrowserType) List(java.util.List) GenericDriverTest(com.seleniumtests.GenericDriverTest) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Aggregations

DriverTestPage (com.seleniumtests.it.driver.support.pages.DriverTestPage)15 Test (org.testng.annotations.Test)9 GenericDriverTest (com.seleniumtests.GenericDriverTest)3 GenericTest (com.seleniumtests.GenericTest)3 TestStepManager (com.seleniumtests.core.TestStepManager)2 CustomEventFiringWebDriver (com.seleniumtests.driver.CustomEventFiringWebDriver)2 TestStep (com.seleniumtests.reporter.logger.TestStep)2 Dimension (org.openqa.selenium.Dimension)2 WebDriver (org.openqa.selenium.WebDriver)2 BeforeClass (org.testng.annotations.BeforeClass)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 BrowserType (com.seleniumtests.driver.BrowserType)1 DriverScrollingTestPage (com.seleniumtests.it.driver.support.pages.DriverScrollingTestPage)1 DriverSubAngularTestPage (com.seleniumtests.it.driver.support.pages.DriverSubAngularTestPage)1 DriverTestAngularFrame (com.seleniumtests.it.driver.support.pages.DriverTestAngularFrame)1 DriverTestPageNativeActions (com.seleniumtests.it.driver.support.pages.DriverTestPageNativeActions)1 DriverTestPageObjectFatory (com.seleniumtests.it.driver.support.pages.DriverTestPageObjectFatory)1 DriverTestPageSalesforceLightning (com.seleniumtests.it.driver.support.pages.DriverTestPageSalesforceLightning)1 DriverTestPageWithoutFixedPattern (com.seleniumtests.it.driver.support.pages.DriverTestPageWithoutFixedPattern)1 WebServer (com.seleniumtests.it.driver.support.server.WebServer)1