Search in sources :

Example 1 with Scroller

use of org.jenkinsci.test.acceptance.selenium.Scroller in project acceptance-test-harness by jenkinsci.

the class SshCredentialDialog method findAndPerformClick.

private void findAndPerformClick(final By addSubmitButtonLocator) {
    final WebElement addSubmitButton = find(addSubmitButtonLocator);
    final Actions builder = new Actions(driver);
    new Scroller().scrollIntoView(addSubmitButton, driver);
    addSubmitButton.click();
    builder.perform();
}
Also used : Actions(org.openqa.selenium.interactions.Actions) Scroller(org.jenkinsci.test.acceptance.selenium.Scroller) WebElement(org.openqa.selenium.WebElement)

Example 2 with Scroller

use of org.jenkinsci.test.acceptance.selenium.Scroller in project acceptance-test-harness by jenkinsci.

the class FallbackConfig method createWebDriver.

/**
 * Creates a {@link WebDriver} for each test, then make sure to clean it up at the end.
 */
@Provides
@TestScope
public WebDriver createWebDriver(TestCleaner cleaner, TestName testName, ElasticTime time) throws IOException {
    WebDriver base = createWebDriver(cleaner, testName);
    // Make sure the window has minimal resolution set, even when out of the visible screen.
    // Note - not maximizing here any more because that doesn't do anything.
    Dimension oldSize = base.manage().window().getSize();
    if (oldSize.height < 1050 || oldSize.width < 1680) {
        base.manage().window().setSize(new Dimension(1680, 1050));
    }
    final EventFiringWebDriver d = new EventFiringWebDriver(base);
    d.register(new Scroller());
    try {
        d.manage().timeouts().pageLoadTimeout(time.seconds(PAGE_LOAD_TIMEOUT), TimeUnit.MILLISECONDS);
        d.manage().timeouts().implicitlyWait(time.seconds(IMPLICIT_WAIT_TIMEOUT), TimeUnit.MILLISECONDS);
    } catch (UnsupportedCommandException e) {
        // sauce labs RemoteWebDriver doesn't support this
        LOGGER.info(base + " doesn't support page load timeout");
    }
    cleaner.addTask(new Statement() {

        @Override
        public void evaluate() {
            switch(getBrowser()) {
                case "firefox":
                case "saucelabs-firefox":
                case "remote-webdriver-firefox":
                    // https://github.com/mozilla/geckodriver/issues/1151
                    // https://bugzilla.mozilla.org/show_bug.cgi?id=1264259
                    // https://bugzilla.mozilla.org/show_bug.cgi?id=1434872
                    d.navigate().to("about:mozilla");
                    Alert alert = ExpectedConditions.alertIsPresent().apply(d);
                    if (alert != null) {
                        alert.accept();
                        d.navigate().refresh();
                    }
            }
            d.quit();
        }

        @Override
        public String toString() {
            return "Close WebDriver after test";
        }
    });
    return d;
}
Also used : WebDriver(org.openqa.selenium.WebDriver) EventFiringWebDriver(org.openqa.selenium.support.events.EventFiringWebDriver) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) UnsupportedCommandException(org.openqa.selenium.UnsupportedCommandException) Statement(org.junit.runners.model.Statement) EventFiringWebDriver(org.openqa.selenium.support.events.EventFiringWebDriver) Alert(org.openqa.selenium.Alert) Dimension(org.openqa.selenium.Dimension) Scroller(org.jenkinsci.test.acceptance.selenium.Scroller) TestScope(org.jenkinsci.test.acceptance.guice.TestScope) Provides(com.google.inject.Provides)

Aggregations

Scroller (org.jenkinsci.test.acceptance.selenium.Scroller)2 Provides (com.google.inject.Provides)1 TestScope (org.jenkinsci.test.acceptance.guice.TestScope)1 Statement (org.junit.runners.model.Statement)1 Alert (org.openqa.selenium.Alert)1 Dimension (org.openqa.selenium.Dimension)1 UnsupportedCommandException (org.openqa.selenium.UnsupportedCommandException)1 WebDriver (org.openqa.selenium.WebDriver)1 WebElement (org.openqa.selenium.WebElement)1 Actions (org.openqa.selenium.interactions.Actions)1 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)1 EventFiringWebDriver (org.openqa.selenium.support.events.EventFiringWebDriver)1