Merge lp:~elopio/selenium-simple-test/multiple-classes into lp:selenium-simple-test

Proposed by Leo Arias
Status: Merged
Approved by: Corey Goldberg
Approved revision: 198
Merge reported by: Corey Goldberg
Merged at revision: not available
Proposed branch: lp:~elopio/selenium-simple-test/multiple-classes
Merge into: lp:selenium-simple-test
Diff against target: 121 lines (+18/-19)
5 files modified
src/sst/actions.py (+9/-8)
src/sst/selftests/get_element.py (+4/-6)
src/testproject/templates/begin.html (+1/-1)
src/testproject/templates/index.html (+2/-2)
src/testproject/templates/longscroll.html (+2/-2)
To merge this branch: bzr merge lp:~elopio/selenium-simple-test/multiple-classes
Reviewer Review Type Date Requested Status
Corey Goldberg (community) Approve
Review via email: mp+77253@code.launchpad.net

Commit message

Fix get_elements action to handle multiple class values. (LP: #860997)

Description of the change

Fix get_elements action to handle multiple class values. (LP: #860997)
This solves the problem on the failing get_element.py selftests, so uncommented them

To post a comment you must log in.
Revision history for this message
Corey Goldberg (coreygoldberg) wrote :

nice.
thanks for getting all get_elements tests to pass!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/sst/actions.py'
2--- src/sst/actions.py 2011-09-27 14:00:36 +0000
3+++ src/sst/actions.py 2011-09-27 23:54:24 +0000
4@@ -757,17 +757,18 @@
5
6 You can specify as many or as few attributes as you like."""
7 selector_string = ''
8- if tag is not None:
9+ if tag:
10 selector_string = tag
11- if css_class is not None:
12- selector_string += ('.%s' % (css_class,))
13- if id is not None:
14- selector_string += ('#%s' % (id,))
15+ if css_class:
16+ css_class_selector = css_class.strip().replace(' ', '.')
17+ selector_string += ('.%s' % css_class_selector)
18+ if id:
19+ selector_string += ('#%s' % id)
20
21 selector_string += ''.join(['[%s=%r]' % (key, value) for
22 key, value in kwargs.items()])
23 try:
24- if text is not None and not selector_string:
25+ if text and not selector_string:
26 elems = browser.find_elements_by_xpath('//*[text() = %r]' % text)
27 else:
28 if not selector_string:
29@@ -778,11 +779,11 @@
30 msg = 'Element not found: %s' % e
31 _raise(msg)
32
33- if text is not None:
34+ if text:
35 # if text was specified, filter elements
36 elems = [element for element in elems if _check_text(element, text)]
37
38- if len(elems) == 0:
39+ if not elems:
40 msg = 'Could not identify elements: 0 elements found'
41 _raise(msg)
42
43
44=== modified file 'src/sst/selftests/get_element.py'
45--- src/sst/selftests/get_element.py 2011-09-24 16:39:47 +0000
46+++ src/sst/selftests/get_element.py 2011-09-27 23:54:24 +0000
47@@ -19,12 +19,12 @@
48 text_is(elem, 'link to longscroll page')
49
50 # unique id + non-unique css_class
51-#elem = get_element(id='longscroll_link', css_class='link class 1') # failing!
52-#text_is(elem, 'link to longscroll page')
53+elem = get_element(id='longscroll_link', css_class='link class a1')
54+text_is(elem, 'link to longscroll page')
55
56 # tag + unique id + non-unique css_class
57-#elem = get_element(tag='a', id='longscroll_link', css_class='link class 1') # failing!
58-#text_is(elem, 'link to longscroll page')
59+elem = get_element(tag='a', id='longscroll_link', css_class='link class a1')
60+text_is(elem, 'link to longscroll page')
61
62 # unique id + tag
63 elem = get_element(tag='a', id='longscroll_link')
64@@ -89,5 +89,3 @@
65 is_radio(elem)
66 elem = get_element(type='radio', name='radio_with_id', checked='1')
67 is_radio(elem)
68-
69-
70
71=== modified file 'src/testproject/templates/begin.html'
72--- src/testproject/templates/begin.html 2011-08-11 18:20:48 +0000
73+++ src/testproject/templates/begin.html 2011-09-27 23:54:24 +0000
74@@ -12,7 +12,7 @@
75 <p class="some_class">More text</p>
76 <p class="some_class">And yet more</p>
77
78- <a class="link class 1" id="the_band_link" href="/">Here is a link</a>
79+ <a class="link class a1" id="the_band_link" href="/">Here is a link</a>
80
81 <form method="post" action="/begin">
82
83
84=== modified file 'src/testproject/templates/index.html'
85--- src/testproject/templates/index.html 2011-09-27 04:21:51 +0000
86+++ src/testproject/templates/index.html 2011-09-27 23:54:24 +0000
87@@ -16,10 +16,10 @@
88 <p class="some_class">More text</p>
89 <p class="some_class">And yet more</p>
90
91- <a class="link class 1" id="the_band_link" href="/begin">Here is a link</a>
92+ <a class="link class a1" id="the_band_link" href="/begin">Here is a link</a>
93
94 <div id="the_div">
95- <a class="link class 1" id="longscroll_link" name="longscroll", href="/longscroll">link to longscroll page</a>
96+ <a class="link class a1" id="longscroll_link" name="longscroll", href="/longscroll">link to longscroll page</a>
97 </div>
98
99 <form method="post" action="/begin">
100
101=== modified file 'src/testproject/templates/longscroll.html'
102--- src/testproject/templates/longscroll.html 2011-09-19 14:59:27 +0000
103+++ src/testproject/templates/longscroll.html 2011-09-27 23:54:24 +0000
104@@ -11,7 +11,7 @@
105 <p class="some_class">More text</p>
106 <p class="some_class">And yet more</p>
107
108- <a class="link class 1" id="homepage_link_top" href="/">go to Homepage</a>
109+ <a class="link class a1" id="homepage_link_top" href="/">go to Homepage</a>
110
111 <form method="post" action="/begin">
112 <div>
113@@ -21,7 +21,7 @@
114 <input type="submit" value="Begin" id="mainform" />
115 </form>
116
117- <a class="link class 1" id="homepage_link_bottom" href="/">go to Homepage</a>
118+ <a class="link class a1" id="homepage_link_bottom" href="/">go to Homepage</a>
119
120 </body>
121 </html>

Subscribers

People subscribed via source and target branches