Search in sources :

Example 1 with HtmlUnitDriver

use of org.openqa.selenium.htmlunit.HtmlUnitDriver in project cucumber-jvm by cucumber.

the class RentACarSupport method getAvailableNumberOfCars.

public int getAvailableNumberOfCars() {
    WebDriver driver = new HtmlUnitDriver();
    try {
        driver.get("http://localhost:9878/rentit/available");
        WebElement availableCars = driver.findElement(By.id("availableCars"));
        String availableCarsString = availableCars.getText();
        return Integer.parseInt(availableCarsString);
    } finally {
        driver.close();
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) HtmlUnitDriver(org.openqa.selenium.htmlunit.HtmlUnitDriver)

Example 2 with HtmlUnitDriver

use of org.openqa.selenium.htmlunit.HtmlUnitDriver in project cucumber-jvm by cucumber.

the class RentACarSupport method rentACar.

public void rentACar() {
    WebDriver driver = new HtmlUnitDriver();
    try {
        driver.get("http://localhost:9878/rentit/rent");
        WebElement rentButton = driver.findElement(By.id("rentButton"));
        rentButton.click();
    } finally {
        driver.close();
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) HtmlUnitDriver(org.openqa.selenium.htmlunit.HtmlUnitDriver)

Example 3 with HtmlUnitDriver

use of org.openqa.selenium.htmlunit.HtmlUnitDriver in project kotlin by JetBrains.

the class SeleniumTest method createDriver.

public static WebDriver createDriver() {
    HtmlUnitDriver answer = new HtmlUnitDriverWithExceptionOnFailingStatusCode();
    answer.setJavascriptEnabled(true);
    return answer;
}
Also used : HtmlUnitDriver(org.openqa.selenium.htmlunit.HtmlUnitDriver)

Example 4 with HtmlUnitDriver

use of org.openqa.selenium.htmlunit.HtmlUnitDriver in project mamute by caelum.

the class AcceptanceTestBase method htmlUnitDriver.

@SuppressWarnings("unused")
private static WebDriver htmlUnitDriver() {
    HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_24);
    driver.setJavascriptEnabled(true);
    return driver;
}
Also used : HtmlUnitDriver(org.openqa.selenium.htmlunit.HtmlUnitDriver)

Example 5 with HtmlUnitDriver

use of org.openqa.selenium.htmlunit.HtmlUnitDriver in project archiva by apache.

the class WebDriverBrowseTest method simpletest.

@Test
public void simpletest() throws Exception {
    Properties p = new Properties();
    p.load(this.getClass().getClassLoader().getResourceAsStream("test.properties"));
    String baseUrl = WebdriverUtility.getBaseUrl();
    String url = baseUrl + "/index.html?request_lang=en";
    goTo(url);
    // wait until topbar-menu-container is feeded
    await().atMost(5, TimeUnit.SECONDS).untilPredicate((fl) -> $("#topbar-menu").present());
    await().atMost(10, TimeUnit.SECONDS).untilPredicate((fl) -> el("#create-admin-link-a").conditions().clickable() || el("#login-link-a").conditions().clickable());
    FluentList<FluentWebElement> elements = find("#create-admin-link-a");
    if (!elements.isEmpty() && elements.get(0).displayed()) {
        WebElement webElement = elements.get(0).getElement();
        Assert.assertEquals("Create Admin User", webElement.getText());
        webElement.click();
        await().atMost(2, TimeUnit.SECONDS).untilPredicate((fl) -> $("#user-create").present());
        assertThat(find("#username").value().equals("admin"));
        assertThat(find("#password").value().isEmpty());
        assertThat(find("#confirmPassword").value().isEmpty());
        assertThat(find("#email").value().isEmpty());
        $("#fullname").fill().with(p.getProperty("ADMIN_FULLNAME"));
        $("#email").fill().with(p.getProperty("ADMIN_EMAIL"));
        $("#password").fill().with(p.getProperty("ADMIN_PASSWORD"));
        $("#confirmPassword").fill().with(p.getProperty("ADMIN_PASSWORD"));
        find("#user-create-form-register-button").click();
        await().atMost(2, TimeUnit.SECONDS).untilPredicate((fl) -> $("#logout-link").present());
        FluentList<FluentWebElement> elementss = find("#menu-find-browse-a");
        WebElement webElsement = elementss.get(0).getElement();
        webElsement.click();
        await().atMost(5, TimeUnit.SECONDS).untilPredicate((fl) -> $("#main_browse_result").present());
        // give me search page :( not  browse page
        takeScreenShot("search.png");
        goTo(baseUrl + "/index.html#browse?request_lang=en");
        takeScreenShot("browse.png");
    // give me a browse page
    } else {
        elements = find(By.id("login-link-a"));
        WebElement webElement = elements.get(0).getElement();
        if (getDriver() instanceof HtmlUnitDriver) {
            Assert.assertEquals("LOGIN", webElement.getText().toUpperCase());
        } else {
            Assert.assertEquals("LOGIN", webElement.getText());
        }
    }
}
Also used : FluentWebElement(org.fluentlenium.core.domain.FluentWebElement) ConfigurationProperties(org.fluentlenium.configuration.ConfigurationProperties) Properties(java.util.Properties) WebElement(org.openqa.selenium.WebElement) FluentWebElement(org.fluentlenium.core.domain.FluentWebElement) HtmlUnitDriver(org.openqa.selenium.htmlunit.HtmlUnitDriver) Test(org.junit.Test) FluentTest(org.fluentlenium.adapter.junit.FluentTest)

Aggregations

HtmlUnitDriver (org.openqa.selenium.htmlunit.HtmlUnitDriver)34 WebElement (org.openqa.selenium.WebElement)10 WebDriver (org.openqa.selenium.WebDriver)9 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)9 ChromeOptions (org.openqa.selenium.chrome.ChromeOptions)9 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)7 InternetExplorerDriver (org.openqa.selenium.ie.InternetExplorerDriver)6 Before (org.junit.Before)5 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)5 URL (java.net.URL)4 SafariDriver (org.openqa.selenium.safari.SafariDriver)4 PublicAtsApi (com.axway.ats.common.PublicAtsApi)3 BrowserVersion (com.gargoylesoftware.htmlunit.BrowserVersion)3 WebClient (com.gargoylesoftware.htmlunit.WebClient)3 File (java.io.File)3 Test (org.junit.Test)3 EdgeDriver (org.openqa.selenium.edge.EdgeDriver)3 PhantomJSDriver (org.openqa.selenium.phantomjs.PhantomJSDriver)3 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2