Skip to content

Commit

Permalink
Implementing FindsByClassName in HtmlUnitDriver using CSS instead of …
Browse files Browse the repository at this point in the history
…XPath
  • Loading branch information
barancev committed Jan 1, 2014
1 parent e2b3aae commit e01454b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion java/client/src/org/openqa/selenium/htmlunit/HtmlUnitDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
import org.openqa.selenium.interactions.HasInputDevices;
import org.openqa.selenium.interactions.Keyboard;
import org.openqa.selenium.interactions.Mouse;
import org.openqa.selenium.internal.FindsByClassName;
import org.openqa.selenium.internal.FindsByCssSelector;
import org.openqa.selenium.internal.FindsById;
import org.openqa.selenium.internal.FindsByLinkText;
Expand Down Expand Up @@ -119,7 +120,7 @@

public class HtmlUnitDriver implements WebDriver, JavascriptExecutor,
FindsById, FindsByLinkText, FindsByXPath, FindsByName, FindsByCssSelector,
FindsByTagName, HasCapabilities, HasInputDevices {
FindsByTagName, FindsByClassName, HasCapabilities, HasInputDevices {

private WebClient webClient;
private WebWindow currentWindow;
Expand Down Expand Up @@ -914,6 +915,16 @@ public List<WebElement> findElementsById(String id) {
return findElementsByXPath("//*[@id='" + id + "']");
}

@Override
public WebElement findElementByClassName(String className) {
return findElementByCssSelector("." + className);
}

@Override
public List<WebElement> findElementsByClassName(String className) {
return findElementsByCssSelector("." + className);
}

public WebElement findElementByCssSelector(String using) {
if (!(lastPage() instanceof HtmlPage)) {
throw new NoSuchElementException("Unable to locate element using css: " + lastPage());
Expand Down

0 comments on commit e01454b

Please sign in to comment.