Skip to content

Commit

Permalink
[java] Changing element finding tests for a weird looking (but a "val…
Browse files Browse the repository at this point in the history
…id") class name
  • Loading branch information
barancev committed Jun 14, 2019
1 parent 1307d3a commit 96ad3c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion common/src/web/xhtmlTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ <h2 class="nameA nameBnoise nameC">An H2 title</h2>
</span>

<div id="parent">I'm a parent
<div id="child">I'm a child</div>
<div id="child" class="cls-!@#$%^&*">I'm a child</div>
</div>

<div id="only-exists-on-xhtmltest">Woo woo</div>
Expand Down
22 changes: 13 additions & 9 deletions java/client/test/org/openqa/selenium/ElementFindingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import static org.openqa.selenium.testing.drivers.Browser.CHROME;
import static org.openqa.selenium.testing.drivers.Browser.CHROMIUMEDGE;
import static org.openqa.selenium.testing.drivers.Browser.EDGE;
import static org.openqa.selenium.testing.drivers.Browser.FIREFOX;
import static org.openqa.selenium.testing.drivers.Browser.HTMLUNIT;
import static org.openqa.selenium.testing.drivers.Browser.IE;
import static org.openqa.selenium.testing.drivers.Browser.MARIONETTE;
import static org.openqa.selenium.testing.drivers.Browser.SAFARI;
Expand Down Expand Up @@ -354,20 +356,22 @@ public void testFindingMultipleElementsByCompoundClassNameShouldThrow() {
}

@Test
public void testFindingASingleElementByInvalidClassNameShouldThrow() {
@NotYetImplemented(FIREFOX)
@NotYetImplemented(HTMLUNIT)
public void testShouldBeAbleToFindASingleElementByAWeirdLookingClassName() {
driver.get(pages.xhtmlTestPage);
assertThatExceptionOfType(NoSuchElementException.class)
.isThrownBy(() -> driver.findElement(By.className("!@#$%^&*")));
WebElement element = driver.findElement(By.className("cls-!@#$%^&*"));
assertThat(element.getAttribute("class")).isEqualTo("cls-!@#$%^&*");
}

@Test
@NotYetImplemented(MARIONETTE)
@NotYetImplemented(SAFARI)
@NotYetImplemented(EDGE)
public void testFindingMultipleElementsByInvalidClassNameShouldThrow() {
@NotYetImplemented(FIREFOX)
@NotYetImplemented(HTMLUNIT)
public void testShouldBeAbleToFindMultipleElementsByAWeirdLookingClassName() {
driver.get(pages.xhtmlTestPage);
assertThatExceptionOfType(NoSuchElementException.class)
.isThrownBy(() -> driver.findElements(By.className("!@#$%^&*")));
List<WebElement> elements = driver.findElements(By.className("cls-!@#$%^&*"));
assertThat(elements).hasSize(1);
assertThat(elements.get(0).getAttribute("class")).isEqualTo("cls-!@#$%^&*");
}

// By.xpath positive
Expand Down

0 comments on commit 96ad3c8

Please sign in to comment.