Skip to content

Commit

Permalink
Fixing "do we need to scroll" condition: we do if the element is not in
Browse files Browse the repository at this point in the history
the parent overflow. Fixes issue 4099
  • Loading branch information
barancev committed Apr 20, 2013
1 parent 6332514 commit a823e0a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
19 changes: 19 additions & 0 deletions common/src/web/scrolling_tests/page_with_double_overflow_auto.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>Page with overflow: auto</title>
<style type="text/css">
html, body {
width: 100%;
height: 100%;
overflow: auto;
}
</style>
</head>
<body>
<div style="height: 5000px;">Placeholder</div>
<div>
<a id="link" href="target_page.html">Click me!</a>
</div>
</body>
</html>
9 changes: 9 additions & 0 deletions common/src/web/scrolling_tests/target_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>Clicked Successfully!</title>
</head>
<body>
<h1>Clicked Successfully!</h1>
</body>
</html>
9 changes: 9 additions & 0 deletions java/client/test/org/openqa/selenium/ClickScrollingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.openqa.selenium.TestWaiter.waitFor;
import static org.openqa.selenium.testing.Ignore.Driver.ANDROID;
import static org.openqa.selenium.testing.Ignore.Driver.CHROME;
import static org.openqa.selenium.testing.Ignore.Driver.HTMLUNIT;
Expand Down Expand Up @@ -89,6 +90,14 @@ public void testShouldBeAbleToClickOnAnElementHiddenByOverflow() {
assertEquals("line8", driver.findElement(By.id("clicked")).getText());
}

@Test
public void testShouldBeAbleToClickOnAnElementHiddenByDoubleOverflow() {
driver.get(appServer.whereIs("scrolling_tests/page_with_double_overflow_auto.html"));

driver.findElement(By.id("link")).click();
waitFor(WaitingConditions.pageTitleToBe(driver, "Clicked Successfully!"));
}

@JavascriptEnabled
@Ignore({OPERA})
@Test
Expand Down
2 changes: 1 addition & 1 deletion javascript/atoms/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ bot.action.LegacyDevice_.findAncestorForm = function(element) {
* @return {boolean} Whether the element is in view after scrolling.
*/
bot.action.scrollIntoView = function(element, opt_coords) {
if (!bot.dom.isScrolledIntoView(element, opt_coords)) {
if (!bot.dom.isScrolledIntoView(element, opt_coords) && !bot.dom.isInParentOverflow(element, opt_coords)) {
// Some elements may not have a scrollIntoView function - for example,
// elements under an SVG element. Call those only if they exist.
if (typeof element.scrollIntoView == 'function') {
Expand Down

0 comments on commit a823e0a

Please sign in to comment.