@Test public void should_be_able_to_find_an_element_using_a_jquery_expression() { StaticSitePage page = getPage(); WebElement link = page.getDriver().findElement(ByJQuery.selector("a[title='Click Me']")); assertThat(link.isDisplayed(), is(true)); }
@Test public void a_jquery_selector_should_be_described_by_the_corresponding_jquery_expression() { ByJQuerySelector jQuerySelector = ByJQuery.selector("a[title='Click Me']"); assertThat(jQuerySelector.toString(), containsString("a[title='Click Me']")); }
@Test(expected = WebDriverException.class) public void should_fail_gracefully_if_jquery_selector_is_invalid() { StaticSitePage page = getPage(); page.getDriver().findElement(ByJQuery.selector("a[title='Does Not Exist'")); }
@Test public void should_be_able_to_find_multiple_elements_using_a_jquery_expression() { StaticSitePage page = getPage(); List<WebElement> links = page.getDriver().findElements(ByJQuery.selector("h2")); assertThat(links.size(), is(2)); }