Skip to content

Commit ce33ca9

Browse files
committed
More new tests for overlapping elements
1 parent 903c2b9 commit ce33ca9

File tree

4 files changed

+169
-0
lines changed

4 files changed

+169
-0
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<title>An element that disappears on click</title>
5+
<style>
6+
#under_under {
7+
position: absolute;
8+
top: 20px;
9+
left: 20px;
10+
width: 100px;
11+
height: 100px;
12+
background-color: white;
13+
}
14+
15+
#under {
16+
position: absolute;
17+
top: 20px;
18+
left: 20px;
19+
width: 100px;
20+
height: 100px;
21+
background-color: blue;
22+
opacity: 0.1;
23+
}
24+
25+
#over1 {
26+
position: absolute;
27+
top: 10px;
28+
left: 10px;
29+
width: 50px;
30+
height: 50px;
31+
background-color: red;
32+
opacity: 0.2;
33+
}
34+
35+
#over2 {
36+
position: absolute;
37+
top: 80px;
38+
left: 10px;
39+
width: 50px;
40+
height: 50px;
41+
background-color: red;
42+
opacity: 0.2;
43+
}
44+
45+
#over3 {
46+
position: absolute;
47+
top: 10px;
48+
left: 80px;
49+
width: 50px;
50+
height: 50px;
51+
background-color: red;
52+
opacity: 0.2;
53+
}
54+
55+
#over4 {
56+
position: absolute;
57+
top: 80px;
58+
left: 80px;
59+
width: 50px;
60+
height: 50px;
61+
background-color: red;
62+
opacity: 0.2;
63+
}
64+
65+
#over5 {
66+
position: absolute;
67+
top: 45px;
68+
left: 45px;
69+
width: 50px;
70+
height: 50px;
71+
background-color: red;
72+
opacity: 0.2;
73+
}
74+
75+
#log {
76+
position: absolute;
77+
top: 120px;
78+
}
79+
</style>
80+
</head>
81+
<body id="body">
82+
<div id="under_under"><p id="contents">Hello</p></div>
83+
<div id="under"><p id="other_contents">Hello</p></div>
84+
<div id="over1"></div>
85+
<div id="over2"></div>
86+
<div id="over3"></div>
87+
<div id="over4"></div>
88+
<div id="over5"></div>
89+
<div id="log">
90+
<p>Log:<p>
91+
</div>
92+
<script>
93+
var byId = document.getElementById.bind(document);
94+
95+
var log = byId("log");
96+
97+
function handler(ev) {
98+
log.innerHTML += "<p></p>";
99+
log.lastElementChild.textContent = ev.type + " in " + ev.target.id + " (handled by " + ev.currentTarget.id + ")\n";
100+
}
101+
102+
var under_under = byId("under_under");
103+
var under = byId("under");
104+
var over1 = byId("over1");
105+
var over2 = byId("over2");
106+
var over3 = byId("over3");
107+
var over4 = byId("over4");
108+
var over5 = byId("over5");
109+
var body = document.body;
110+
111+
var types = ["click", "mousedown", "mouseup"];
112+
for (var i = 0, type; (type = types[i]); ++i) {
113+
under_under.addEventListener(type, handler);
114+
under.addEventListener(type, handler);
115+
over1.addEventListener(type, handler);
116+
over2.addEventListener(type, handler);
117+
over3.addEventListener(type, handler);
118+
over4.addEventListener(type, handler);
119+
over5.addEventListener(type, handler);
120+
body.addEventListener(type, handler);
121+
}
122+
</script>
123+
</body>
124+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<title>A wrapped element with overlapped first part</title>
5+
</head>
6+
<body id="body">
7+
<div style="width:300px">
8+
<div style="float:left;width:200px;background:green;">placeholder</div>
9+
<div style="float:left; position:absolute;width:100px;margin-left:200px;background:red;opacity:0.5;">Over</div>
10+
<a id="link" href="submitted_page.html">Link that continues on next line</a>
11+
</div>
12+
</body>
13+
</html>

java/client/test/org/openqa/selenium/ClickTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,4 +359,15 @@ public void testShouldBeAbleToClickOnASpanThatWrapsToTheNextLine() {
359359

360360
wait.until(titleIs("Submitted Successfully!"));
361361
}
362+
363+
@JavascriptEnabled
364+
@Test
365+
@Ignore(value = {CHROME, IE, MARIONETTE, SAFARI})
366+
public void testShouldBeAbleToClickOnAPartiallyOverlappedLinkThatWrapsToTheNextLine() {
367+
driver.get(appServer.whereIs("click_tests/wrapped_overlapping_elements.html"));
368+
369+
driver.findElement(By.id("link")).click();
370+
371+
wait.until(titleIs("Submitted Successfully!"));
372+
}
362373
}

java/client/test/org/openqa/selenium/CorrectEventFiringTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,27 @@ public void testClickOverlappingElements() {
432432
fail("Should have thrown Exception with 'Other element would receive the click' in the message");
433433
}
434434

435+
@JavascriptEnabled
436+
@Ignore(value = {CHROME, IE, MARIONETTE, SAFARI, HTMLUNIT})
437+
@Test
438+
public void testClickPartiallyOverlappingElements() {
439+
assumeFalse(isOldIe(driver));
440+
for (int i = 1; i < 6; i++) {
441+
driver.get(appServer.whereIs("click_tests/partially_overlapping_elements.html"));
442+
WebElement over = driver.findElement(By.id("over" + i));
443+
((JavascriptExecutor) driver).executeScript("arguments[0].style.display = 'none'", over);
444+
driver.findElement(By.id("under")).click();
445+
assertEquals(driver.findElement(By.id("log")).getText(),
446+
"Log:\n"
447+
+ "mousedown in under (handled by under)\n"
448+
+ "mousedown in under (handled by body)\n"
449+
+ "mouseup in under (handled by under)\n"
450+
+ "mouseup in under (handled by body)\n"
451+
+ "click in under (handled by under)\n"
452+
+ "click in under (handled by body)");
453+
}
454+
}
455+
435456
@JavascriptEnabled
436457
@Ignore(value = {CHROME, FIREFOX, SAFARI, HTMLUNIT})
437458
@Test

0 commit comments

Comments
 (0)