DomSelector implements Serializable { public WebElement findElement(WebDriver driver) { if (parentSelector == null) { return type.findElement(driver, value); } WebElement frameElement = parentSelector.findElement(driver); return type.findElement(frameElement, value); } DomSelector(SelectorType type, String value); @JsonCreator  DomSelector(@JsonProperty("type") SelectorType type, @JsonProperty("value") String value,
			@JsonProperty("parentSelector") DomSelector parentSelector); SelectorType getType(); String getValue(); DomSelector getParentSelector(); WebElement findElement(WebDriver driver); WebElement findElement(WebElement element); @SuppressWarnings("unchecked") List<WebElement> findElements(WebDriver driver); @SuppressWarnings("unchecked") List<WebElement> findElements(WebElement element); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }
@Test public void findElement_driver() throws Exception { DomSelector selector = new DomSelector(SelectorType.TAG_NAME, "body"); assertThat(selector.findElement(driver), is(defaultContentElement)); }
@Test public void findElement_driver_notFound() throws Exception { expectedException.expect(NoSuchElementException.class); DomSelector selector = new DomSelector(SelectorType.TAG_NAME, "none"); selector.findElement(driver); }
@Test public void findElement_element() throws Exception { DomSelector selector = new DomSelector(SelectorType.ID, "main"); assertThat(selector.findElement(defaultContentElement), is(parentElement)); }
@Test public void findElement_element_notFound() throws Exception { expectedException.expect(NoSuchElementException.class); DomSelector selector = new DomSelector(SelectorType.ID, "none"); selector.findElement(defaultContentElement); }
@Test public void findElement_driver_nested() throws Exception { DomSelector selector = new DomSelector(SelectorType.ID, "main", new DomSelector(SelectorType.TAG_NAME, "body")); assertThat(selector.findElement(driver), is(parentElement)); }
@Test public void findElement_driver_nested_notFound() throws Exception { expectedException.expect(NoSuchElementException.class); DomSelector selector = new DomSelector(SelectorType.ID, "none", new DomSelector(SelectorType.TAG_NAME, "body")); selector.findElement(driver); }
@Test public void findElement_element_nested() throws Exception { DomSelector selector = new DomSelector(SelectorType.CLASS_NAME, "child", new DomSelector(SelectorType.ID, "main")); assertThat(selector.findElement(defaultContentElement), is(childElement)); }
@Test public void findElement_element_nested_notFound() throws Exception { expectedException.expect(NoSuchElementException.class); DomSelector selector = new DomSelector(SelectorType.CLASS_NAME, "none", new DomSelector(SelectorType.ID, "main")); selector.findElement(defaultContentElement); }
@Test public void findElement_element_nested_notFound_parent() throws Exception { expectedException.expect(NoSuchElementException.class); DomSelector selector = new DomSelector(SelectorType.CLASS_NAME, "child", new DomSelector(SelectorType.ID, "none")); selector.findElement(defaultContentElement); }