Search in sources :

Example 1 with FluentWebDriver

use of org.seleniumhq.selenium.fluent.FluentWebDriver in project selenium_java by sergueik.

the class AngularAndWebDriverTest method basic_locators_by_repeater_should_find_one_row_by_partial_match.

/*
	  Ported from protractor/spec/basic/locators_spec.js
	  TODO - many more specs in here
	 */
@Test(enabled = false)
public void basic_locators_by_repeater_should_find_one_row_by_partial_match() {
    FluentWebDriver fwd = new FluentWebDriver(driver);
    driver.get("http://localhost:8080/index.html#/repeater");
    fwd.li(ByAngular.repeater("baz in days | filter:'T'").row(0)).getText().shouldBe("T");
    fwd.li(ByAngular.repeater("baz in days | filter:'T'").row(1)).getText().shouldBe("Th");
    fwd.li(ByAngular.repeater("baz in days | filt").row(1)).getText().shouldBe("Th");
    try {
        fwd.li(ByAngular.exactRepeater("baz in days | filt").row(1)).getText().shouldBe("T");
        fail("should have barfed");
    } catch (FluentExecutionStopped e) {
        assertThat(e.getMessage(), startsWith("NoSuchElementException during invocation of: ?.li(exactRepeater(baz in days | filt).row(1))"));
        assertThat(e.getCause().getMessage(), startsWith("exactRepeater(baz in days | filt).row(1) didn't have any matching elements at this place in the DOM"));
    }
}
Also used : FluentWebDriver(org.seleniumhq.selenium.fluent.FluentWebDriver) FluentExecutionStopped(org.seleniumhq.selenium.fluent.FluentExecutionStopped) Test(org.testng.annotations.Test)

Example 2 with FluentWebDriver

use of org.seleniumhq.selenium.fluent.FluentWebDriver in project selenium_java by sergueik.

the class AngularAndWebDriverTest method basic_locators_by_repeater_should_find_by_partial_match.

/*
	  Ported from protractor/spec/basic/locators_spec.js
	  TODO - many more specs in here
	 */
@Test(enabled = false)
public void basic_locators_by_repeater_should_find_by_partial_match() {
    FluentWebDriver fwd = new FluentWebDriver(driver);
    driver.get("http://localhost:8080/index.html#/repeater");
    fwd.span(ByAngular.repeater("baz in days | filter:'T'").row(0).column("baz.initial")).getText().shouldBe("T");
    fwd.span(ByAngular.repeater("baz in days | fil").row(0).column("baz.initial")).getText().shouldBe("T");
    try {
        fwd.li(ByAngular.exactRepeater("baz in days | fil").row(0).column("baz.initial")).getText().shouldBe("T");
        fail("should have barfed");
    } catch (FluentExecutionStopped e) {
        assertThat(e.getMessage(), startsWith("NoSuchElementException during invocation of: ?.li(exactRepeater(baz in days | fil).row(0).column(baz.initial))"));
        assertThat(e.getCause().getMessage(), startsWith("exactRepeater(baz in days | fil).row(0).column(baz.initial) didn't have any matching elements at this place in the DOM"));
    }
}
Also used : FluentWebDriver(org.seleniumhq.selenium.fluent.FluentWebDriver) FluentExecutionStopped(org.seleniumhq.selenium.fluent.FluentExecutionStopped) Test(org.testng.annotations.Test)

Example 3 with FluentWebDriver

use of org.seleniumhq.selenium.fluent.FluentWebDriver in project selenium_java by sergueik.

the class AngularAndWebDriverTest method basic_locators_by_repeater_should_find_many_rows_by_partial_match.

/*
	  Ported from protractor/spec/basic/locators_spec.js
	  TODO - many more specs in here
	 */
@Test(enabled = false)
public void basic_locators_by_repeater_should_find_many_rows_by_partial_match() {
    FluentWebDriver fwd = new FluentWebDriver(driver);
    driver.get("http://localhost:8080/index.html#/repeater");
    FluentWebElements spans = fwd.spans(ByAngular.repeater("baz in days | filter:'T'").column("baz.initial"));
    spans.getText().shouldBe("TTh");
    spans.get(0).getText().shouldBe("T");
    spans.get(1).getText().shouldBe("Th");
    spans = fwd.spans(ByAngular.repeater("baz in days | fil").column("baz.initial"));
    spans.getText().shouldBe("TTh");
    spans.get(0).getText().shouldBe("T");
    spans.get(1).getText().shouldBe("Th");
    try {
        fwd.li(ByAngular.exactRepeater("baz in days | fil").column("baz.initial")).getText().shouldBe("TTh");
        fail("should have barfed");
    } catch (FluentExecutionStopped e) {
        assertThat(e.getMessage(), startsWith("NoSuchElementException during invocation of: ?.li(exactRepeater(baz in days | fil).column(baz.initial))"));
        assertThat(e.getCause().getMessage(), startsWith("exactRepeater(baz in days | fil).column(baz.initial) didn't have any matching elements at this place in the DOM"));
    }
}
Also used : FluentWebDriver(org.seleniumhq.selenium.fluent.FluentWebDriver) FluentExecutionStopped(org.seleniumhq.selenium.fluent.FluentExecutionStopped) FluentWebElements(org.seleniumhq.selenium.fluent.FluentWebElements) Test(org.testng.annotations.Test)

Example 4 with FluentWebDriver

use of org.seleniumhq.selenium.fluent.FluentWebDriver in project selenium_java by sergueik.

the class AngularAndWebDriverTest method basic_lib_getLocationAbsUrl_gets_url.

/*
	  Ported from protractor/spec/basic/lib_spec.js
	  TODO - many more specs in here
	 */
@Test(enabled = false)
public void basic_lib_getLocationAbsUrl_gets_url() {
    FluentWebDriver fwd = new FluentWebDriver(driver);
    driver.get("http://localhost:8080/index.html");
    assertThat(ngWebDriver.getLocationAbsUrl(), endsWith("/form"));
    fwd.link(By.linkText("repeater")).click();
    assertThat(ngWebDriver.getLocationAbsUrl(), endsWith("/repeater"));
}
Also used : FluentWebDriver(org.seleniumhq.selenium.fluent.FluentWebDriver) Test(org.testng.annotations.Test)

Example 5 with FluentWebDriver

use of org.seleniumhq.selenium.fluent.FluentWebDriver in project selenium_java by sergueik.

the class AngularAndWebDriverTest method stress_test.

/*
	  Ported from protractor/stress/spec.js
	 */
@Test(enabled = false)
public void stress_test() {
    FluentWebDriver fwd = new FluentWebDriver(driver);
    for (int i = 0; i < 20; ++i) {
        resetBrowser();
        driver.get("http://localhost:8080/index.html#/form");
        FluentWebElement usernameInput = fwd.input(ByAngular.model("username"));
        FluentWebElement name = fwd.span(ByAngular.binding("username"));
        ngWebDriver.waitForAngularRequestsToFinish();
        name.getText().shouldBe("Anon");
        usernameInput.clearField().sendKeys("B");
        name.getText().shouldBe("B");
    }
}
Also used : FluentWebDriver(org.seleniumhq.selenium.fluent.FluentWebDriver) FluentWebElement(org.seleniumhq.selenium.fluent.FluentWebElement) Test(org.testng.annotations.Test)

Aggregations

FluentWebDriver (org.seleniumhq.selenium.fluent.FluentWebDriver)15 Test (org.testng.annotations.Test)12 FluentExecutionStopped (org.seleniumhq.selenium.fluent.FluentExecutionStopped)5 FluentWebElement (org.seleniumhq.selenium.fluent.FluentWebElement)4 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)3 ChromeOptions (org.openqa.selenium.chrome.ChromeOptions)2 FluentWebElements (org.seleniumhq.selenium.fluent.FluentWebElements)2 HashMap (java.util.HashMap)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 BeforeClass (org.junit.BeforeClass)1 Actions (org.openqa.selenium.interactions.Actions)1