"Fossies" - the Fresh Open Source Software Archive 
Member "selenium-selenium-4.8.1/javascript/selenium-atoms/test/selenium_locators_test.html" (17 Feb 2023, 2608 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:
The requested HTML page contains a <FORM> tag that is unusable on "Fossies" in "automatic" (rendered) mode so that page is shown as HTML source code syntax highlighting (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1 <html>
2 <head>
3 <title>selenium_locators_test</title>
4 <script type="text/javascript" src="test_bootstrap.js"></script>
5 <script type="text/javascript">
6 goog.require('goog.testing.jsunit');
7 goog.require('bot.dom');
8 goog.require('core.locators');
9 </script>
10
11 <script type="text/javascript">
12 function testShouldBeAbleToFindById() {
13 var element = core.locators.findElement('id=find_by_id');
14
15 assertEquals('find_by_id', bot.dom.getAttribute(element, 'id'));
16 }
17
18 function testShouldBeAbleToFindByName() {
19 var element = core.locators.findElement('name=find_by_name');
20
21 assertEquals('find_by_name', bot.dom.getAttribute(element, 'name'));
22 }
23
24 function testImplicitLocatorFindsByIdOrName() {
25 var element = core.locators.findElement('find_by_id');
26 assertEquals('find_by_id', bot.dom.getAttribute(element, 'id'));
27
28 element = core.locators.findElement('find_by_name');
29 assertEquals('find_by_name', bot.dom.getAttribute(element, 'name'));
30 }
31
32 function testShouldFindElementsByXPath() {
33 if (!document['evaluate']) { return; } // XPath not available
34
35 var element = core.locators.findElement('//input');
36 assertEquals('find_by_name', bot.dom.getAttribute(element, 'name'));
37 }
38
39 function testShouldFindElementsIterativelyImplicitly() {
40 var element = core.locators.findElement('in_child_frame');
41 assertEquals('in_child_frame', bot.dom.getAttribute(element, 'id'));
42 }
43
44 function testShouldFindElementsIterativelyById() {
45 var element = core.locators.findElement('id=in_child_frame');
46 assertEquals('in_child_frame', bot.dom.getAttribute(element, 'id'));
47 }
48
49 function testShouldFindElementsIterativelyByImplicitXPath() {
50 if (!document['evaluate']) { return; } // XPath not available
51
52 var element = core.locators.findElement('//*[@id = "in_child_frame"]');
53 assertEquals('in_child_frame', bot.dom.getAttribute(element, 'id'));
54 }
55
56 function testCanAddAStrategy() {
57 var expected = bot.locators.findElement({id: 'find_by_id'});
58 core.locators.addStrategy("foo", function() {
59 return expected;
60 });
61
62 var found = core.locators.findElement('foo=bar');
63 assertEquals(expected, found);
64 }
65 </script>
66 </head>
67 <body>
68 <form action="#">
69 <input name="find_by_name">
70 </form>
71 <div id="find_by_id">Example div</div>
72
73 <iframe src="./testdata/iterative_locators_page.html">
74 </iframe>
75 </body>
76 </html>