Skip to content

HtmlUnitDriver does not evaluate CSS3 pseudo class :target correctly #46

Description

@lklonowski

When accessing a website with an anchor, CSS styles for a matching :target do not apply as expected.

Minimal test site:

<!DOCTYPE html>
<html>
<head>
<style>
.tab div {
    display: none;
}

.tab div:target {
    display: block;
}
</style>
</head>
<body>
<div class="tab">
<a id="link" href="#anchor">Link</a>   
<div id="anchor">
  <p>Content</p>
</div>
</div>
</body>
</html>

Minimal Java test code:

getWebDriver().get(TEST_URL);
getWebDriver().findElement(By.id("link")).click();
System.out.println(getWebDriver().findElement(By.id("anchor")).isDisplayed());
getWebDriver().get(TEST_URL + "#anchor");
System.out.println(getWebDriver().findElement(By.id("anchor")).isDisplayed());

Result:
Both times 'false' ist printed.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions