Merge lp:~elopio/selenium-simple-test/is-displayed into lp:selenium-simple-test

Proposed by Leo Arias
Status: Merged
Merge reported by: Corey Goldberg
Merged at revision: not available
Proposed branch: lp:~elopio/selenium-simple-test/is-displayed
Merge into: lp:selenium-simple-test
Diff against target: 60 lines (+25/-3)
3 files modified
src/sst/actions.py (+14/-2)
src/sst/selftests/element_is_displayed.py (+10/-0)
src/testproject/templates/index.html (+1/-1)
To merge this branch: bzr merge lp:~elopio/selenium-simple-test/is-displayed
Reviewer Review Type Date Requested Status
Corey Goldberg (community) Approve
Review via email: mp+77094@code.launchpad.net

Commit message

Added the element_is_displayed action (Fixes bug #860264)

Description of the change

Added the element_is_displayed action, that will raise an exception if the element is not displayed (LP: #860264)

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

wondering if "element_is_displayed(id_or_elem)" should be named "is_displayed(id_or_elem)" ?
what do you think about the naming?

otherwise, looks good!

Revision history for this message
Corey Goldberg (coreygoldberg) wrote :

I made the name change to "is_displayed(id_or_elem)" in my branch:
https://code.launchpad.net/~coreygoldberg/selenium-simple-test/new-is_displayed

I'll merge that branch with this one as a prerequisite.

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-26 04:27:25 +0000
3+++ src/sst/actions.py 2011-09-27 05:39:23 +0000
4@@ -69,8 +69,8 @@
5 'set_wait_timeout', 'get_argument', 'run_test', 'get_base_url',
6 'end_test', 'skip', 'get_element_by_css', 'get_elements_by_css',
7 'take_screenshot', 'debug', 'get_page_source', 'simulate_keys',
8- 'element_click', 'get_element_by_xpath', 'get_elements_by_xpath',
9- 'switch_to_window', 'switch_to_frame'
10+ 'element_is_displayed', 'element_click', 'get_element_by_xpath',
11+ 'get_elements_by_xpath', 'switch_to_window', 'switch_to_frame'
12 ]
13
14
15@@ -433,6 +433,18 @@
16 url_is(link_url)
17
18
19+def element_is_displayed(id_or_elem):
20+ """
21+ Assert that the element is displayed. Takes an id or an element object.
22+ Raises a failure exception if the element specified doesn't exist or isn't
23+ displayed. Returns the element if it is displayed."""
24+ element = _get_elem(id_or_elem)
25+ if not element.is_displayed():
26+ message = 'Element is not displayed'
27+ _raise(message)
28+ return element
29+
30+
31 def element_click(id_or_elem, wait=True):
32 """
33 Click on an element of any kind not specific to links or buttons.
34
35=== added file 'src/sst/selftests/element_is_displayed.py'
36--- src/sst/selftests/element_is_displayed.py 1970-01-01 00:00:00 +0000
37+++ src/sst/selftests/element_is_displayed.py 2011-09-27 05:39:23 +0000
38@@ -0,0 +1,10 @@
39+import os
40+from sst.actions import *
41+
42+"""Test the element_is_displayed action."""
43+
44+
45+goto('/')
46+
47+element_is_displayed('select_with_id_1')
48+fails(element_is_displayed, 'hidden_input')
49
50=== modified file 'src/testproject/templates/index.html'
51--- src/testproject/templates/index.html 2011-09-26 03:12:05 +0000
52+++ src/testproject/templates/index.html 2011-09-27 05:39:23 +0000
53@@ -138,6 +138,6 @@
54 </form>
55
56 <a id="popup_link" href="popup_with_frame.html" target="_NEW_WINDOW">Popup</a>
57-
58+ <input type="hidden" id="hidden_input" />
59 </body>
60 </html>

Subscribers

People subscribed via source and target branches