Skip to content

Commit f7e1e3c

Browse files
committed
Deleting the unused SeCore code
1 parent cff1bf0 commit f7e1e3c

79 files changed

Lines changed: 153 additions & 39146 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

java/client/test/org/openqa/selenium/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
load("@rules_jvm_external//:defs.bzl", "artifact")
22
load("//java:defs.bzl", "java_library", "java_selenium_test_suite", "java_test_suite")
33

4+
5+
load("@apple_rules_lint//lint:defs.bzl", "package_lint_config")
6+
7+
package_lint_config({
8+
"java-spotbugs": "//java/client/test/org/openqa/selenium:test-spotbugs-config",
9+
})
10+
411
SMALL_TESTS = [
512
"ArchitectureTest.java",
613
"ByTest.java",

javascript/atoms/locators/relative.js

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ bot.locators.relative.near_ = function(selector, opt_distance) {
152152
distance = 50;
153153
}
154154

155-
156155
/**
157156
* @param {!Element} compareTo
158157
* @return {boolean}
@@ -251,6 +250,13 @@ bot.locators.relative.STRATEGIES_ = {
251250
'near': bot.locators.relative.near_,
252251
};
253252

253+
bot.locators.relative.RESOLVERS_ = {
254+
'left': bot.locators.relative.resolve_,
255+
'right': bot.locators.relative.resolve_,
256+
'above': bot.locators.relative.resolve_,
257+
'below': bot.locators.relative.resolve_,
258+
'near': bot.locators.relative.resolve_,
259+
};
254260

255261
/**
256262
* @param {!IArrayLike<!Element>} allElements
@@ -292,7 +298,55 @@ bot.locators.relative.filterElements_ = function(allElements, filters) {
292298
},
293299
null);
294300

295-
return toReturn;
301+
// We want to sort the returned elements by proximity to the last "anchor"
302+
// element in the filters.
303+
var finalFilter = goog.array.last(filters);
304+
var name = finalFilter["kind"];
305+
var resolver = bot.locators.relative.RESOLVERS_[name];
306+
if (!!!resolver) {
307+
return toReturn;
308+
}
309+
var lastAnchor = resolver.apply(null, finalFilter["args"]);
310+
if (!!!lastAnchor) {
311+
return toReturn;
312+
}
313+
314+
return bot.locators.relative.sortByProximity_(lastAnchor, toReturn);
315+
};
316+
317+
318+
/**
319+
* @param {!Element} anchor
320+
* @param {!Array<!Element>} elements
321+
* @return {!Array<!Element>}
322+
* @private
323+
*/
324+
bot.locators.relative.sortByProximity_ = function(anchor, elements) {
325+
console.log("Anchor is", anchor);
326+
var anchorRect = bot.dom.getClientRect(anchor);
327+
var anchorCenter = {
328+
x: anchorRect.left + (Math.max(1, anchorRect.width) / 2),
329+
y: anchorRect.top + (Math.max(1, anchorRect.height) / 2)
330+
};
331+
332+
var distance = function(e) {
333+
var rect = bot.dom.getClientRect(e);
334+
var center = {
335+
x: rect.left + (Math.max(1, rect.width) / 2),
336+
y: rect.height + (Math.max(1, rect.height) / 2)
337+
};
338+
339+
var x = Math.pow(Math.abs(anchorCenter.x - center.x), 2);
340+
var y = Math.pow(Math.abs(anchorCenter.y - center.y), 2);
341+
342+
return Math.sqrt(x + y);
343+
};
344+
345+
goog.array.sort(elements, function(left, right) {
346+
return distance(left) - distance(right);
347+
});
348+
349+
return elements;
296350
};
297351

298352

javascript/atoms/test/relative_locator_test.html

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,49 @@
1010
td {
1111
border: solid;
1212
}
13+
#proximity-tests {
14+
position: relative;
15+
padding: 10px;
16+
border: 1px solid black;
17+
width: 640px;
18+
height: 480px;
19+
}
20+
21+
#proxima1 {
22+
position: absolute;
23+
top: 310px;
24+
left: 230px;
25+
height: 40px;
26+
width: 40px;
27+
background-color: red;
28+
}
29+
30+
#proxima2 {
31+
position: absolute;
32+
top: 100px;
33+
left: 100px;
34+
height: 40px;
35+
width: 40px;
36+
background-color: green;
37+
}
38+
39+
#proxima3 {
40+
position: absolute;
41+
top: 150px;
42+
left: 310px;
43+
height: 40px;
44+
width: 40px;
45+
background-color: yellow;
46+
}
47+
48+
#proxima4 {
49+
position: absolute;
50+
top: 400px;
51+
left: 150px;
52+
height: 40px;
53+
width: 40px;
54+
background-color: blue;
55+
}
1356
</style>
1457
<script src="test_bootstrap.js"></script>
1558
<script type="text/javascript">
@@ -119,6 +162,53 @@
119162
assertEquals("below", found[0].getAttribute("id"));
120163
}
121164

165+
function testShouldOrderNodesByProximity() {
166+
// Create an iframe to hold the content
167+
var frame = document.createElement("iframe");
168+
var pageSource = "" +
169+
"<head>" +
170+
"<style>" +
171+
"#proxima1 {position: absolute;\n top: 310px;\n left: 230px;\n height: 40px;\n width: 40px;\n background-color: red;}\n" +
172+
"#proxima2 {position: absolute;\n top: 100px;\n left: 100px;\n height: 40px;\n width: 40px;\n background-color: green;}\n" +
173+
"#proxima3 {position: absolute;\n top: 150px;\n left: 310px;\n height: 40px;\n width: 40px;\n background-color: yellow;}\n" +
174+
"#proxima4 {position: absolute;\n top: 400px;\n left: 150px;\n height: 40px;\n width: 40px;\n background-color: blue;}\n" +
175+
"</style>" +
176+
"</head>" +
177+
"<div id=\"proxima1\">a</div>\n<div id=\"proxima2\">b</div>\n<div id=\"proxima3\">c</div>\n<div id=\"proxima4\">d</div>\n"
178+
"";
179+
frame.setAttribute("width", 640);
180+
frame.setAttribute("height", 480);
181+
// frame.src = "data:text/html;charset=utf-8," + encodeURI(pageSource);
182+
document.body.appendChild(frame);
183+
184+
var win = goog.dom.getFrameContentWindow(frame);
185+
win.document.documentElement.innerHTML = pageSource;
186+
187+
var current = bot.getWindow();
188+
189+
try {
190+
bot.setWindow(goog.dom.getFrameContentWindow(frame));
191+
192+
var red = bot.locators.findElement({id: "proxima1"});
193+
var green = bot.locators.findElement({id: "proxima2"});
194+
var yellow = bot.locators.findElement({id: "proxima3"});
195+
var blue = bot.locators.findElement({id: "proxima4"});
196+
197+
var found = bot.locators.findElements({
198+
relative: {
199+
root: {tagName: "div"},
200+
filters: [{kind: "near", args: [red, 400]}]
201+
}
202+
})
203+
204+
console.log(found);
205+
206+
assertEquals([blue, yellow, green], found);
207+
} finally {
208+
bot.setWindow(current);
209+
}
210+
}
211+
122212
</script>
123213
</head>
124214
<body>

javascript/selenium-core/Blank.html

Lines changed: 0 additions & 7 deletions
This file was deleted.

javascript/selenium-core/InjectedRemoteRunner.html

Lines changed: 0 additions & 8 deletions
This file was deleted.

javascript/selenium-core/RemoteRunner.html

Lines changed: 0 additions & 102 deletions
This file was deleted.

0 commit comments

Comments
 (0)