Merge lp:~ara/mago/firefox_natty into lp:~mago-contributors/mago/mago-1.0

Proposed by Ara Pulido
Status: Merged
Merged at revision: 156
Proposed branch: lp:~ara/mago/firefox_natty
Merge into: lp:~mago-contributors/mago/mago-1.0
Diff against target: 290 lines (+191/-16)
5 files modified
firefox/README (+19/-0)
firefox/firefox_basics.py (+34/-2)
firefox/firefox_basics.xml (+25/-7)
mago/application/firefox.py (+108/-5)
mago/test_suite/firefox.py (+5/-2)
To merge this branch: bzr merge lp:~ara/mago/firefox_natty
Reviewer Review Type Date Requested Status
Jean-Baptiste Lallement Approve
Review via email: mp+43176@code.launchpad.net

Description of the change

Firefox tests for Natty

Including:

* Open a given URL
* Search a given text in Google
* Open a new tab and close it
* Add a new bookmark and delete it

To post a comment you must log in.
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

With a new profile the default page is displayed and the page requested by the test is opened on another tab.
When the test tries to close firefox, a dialog is displayed saying that more than 1 tab is opened and asking for confirmation before closing.
This dialog makes the test fail.

review: Needs Fixing
Revision history for this message
Ara Pulido (ara) wrote :

Thanks for your review! I will change the setup so it closes the extra tabs when it opens.

Revision history for this message
Ara Pulido (ara) wrote :

/me <3 jibel

lp:~ara/mago/firefox_natty updated
154. By Ara Pulido

Fixed setup to leave only one tab to start with

Revision history for this message
Ara Pulido (ara) wrote :

I have fixed the setup method to close all the additional tabs and start fresh with only one.
Can you please rereview?

Thanks!

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Rereviewed and looks good. Many thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'firefox/README'
2--- firefox/README 2010-11-23 22:02:09 +0000
3+++ firefox/README 2010-12-09 14:59:10 +0000
4@@ -0,0 +1,19 @@
5+BANSHEE TESTS
6+=============
7+
8+Safety
9+------
10+The tests are safe to run
11+
12+Configuration
13+-------------
14+The tests assume that there is a network connection
15+
16+Available Tests
17+---------------
18+
19+* Open a given URL
20+* Search a given text in Google
21+* Open a new tab and close it
22+* Add a new bookmark and delete it
23+
24
25=== modified file 'firefox/firefox_basics.py'
26--- firefox/firefox_basics.py 2010-11-23 22:02:09 +0000
27+++ firefox/firefox_basics.py 2010-12-09 14:59:10 +0000
28@@ -5,9 +5,41 @@
29 from mago.test_suite.firefox import FirefoxTestSuite
30
31 class FirefoxBasics(FirefoxTestSuite):
32- def testAboutdialog(self, arg1=None):
33- self.application.runAboutdialog()
34+
35+ def testOpenURL(self, url, window_name_oracle):
36+ self.application.open_url(url)
37+ window_name = self.application.get_window_name()
38+
39+ if window_name != window_name_oracle:
40+ raise AssertionError, "The URL %s was not correctly opened. Window expected: %s, got: %s" % (url, window_name_oracle, window_name)
41+
42+
43+ def testGoogleSearch(self, search_text, window_name_oracle):
44+ self.application.search_google(search_text)
45+ window_name = self.application.get_window_name()
46+ window_name_oracle = search_text + window_name_oracle
47+
48+ if window_name != window_name_oracle:
49+ raise AssertionError, "The Google Search for %s was not correctly opened. Window expected: %s, got: %s" % (search_text, window_name_oracle, window_name)
50+
51+ def testTabs(self):
52+ number_tabs = self.application.number_of_tabs()
53+ self.application.open_new_tab()
54+ number_tabs_after = self.application.number_of_tabs()
55+
56+ if (number_tabs + 1) != number_tabs_after:
57+ raise AssertionError, "The tab was not created. Number of tabs expected %s, got %s" % (str(number_tabs + 1), str(number_tabs_after))
58
59+ self.application.close_current_tab()
60+ number_tabs = self.application.number_of_tabs()
61+
62+ if (number_tabs + 1) != number_tabs_after:
63+ raise AssertionError, "The tab was not created. Number of tabs expected %s, got %s" % (str(number_tabs_after - 1), str(number_tabs))
64+
65+ def testBookmarks(self):
66+ self.application.add_bookmark()
67+ self.application.remove_bookmark()
68+
69 if __name__ == "__main__":
70 firefox_test = FirefoxBasics()
71 firefox_test.run()
72
73=== modified file 'firefox/firefox_basics.xml'
74--- firefox/firefox_basics.xml 2010-11-23 22:02:09 +0000
75+++ firefox/firefox_basics.xml 2010-12-09 14:59:10 +0000
76@@ -4,11 +4,29 @@
77 <description>
78 Tests which verify Firefox basics functionality.
79 </description>
80- <case name="about_dialog">
81- <method>testAboutdialog</method>
82- <description>Verify that the about dialog launches</description>
83- <args>
84- <arg1>Arg example</arg1>
85- </args>
86- </case>
87+ <case name="open_url">
88+ <method>testOpenURL</method>
89+ <description>Verify that a particular URL is opened</description>
90+ <args>
91+ <url>http://www.ubuntu.com</url>
92+ <window_name_oracle>Ubuntuhomepage|Ubuntu</window_name_oracle>
93+ </args>
94+ </case>
95+ <case name="search_google">
96+ <method>testGoogleSearch</method>
97+ <description>Verify that Google search works correctly</description>
98+ <args>
99+ <search_text>Ubuntu</search_text>
100+ <window_name_oracle>-GoogleSearch</window_name_oracle>
101+ </args>
102+ </case>
103+ <case name="play_with_tabs">
104+ <method>testTabs</method>
105+ <description>Verify that creation and deletion of tabs works correctly</description>
106+ </case>
107+ <case name="bookmarks">
108+ <method>testBookmarks</method>
109+ <description>Verify that creation and deletion of bookmarks works correctly</description>
110+ </case>
111 </suite>
112+
113
114=== modified file 'mago/application/firefox.py'
115--- mago/application/firefox.py 2010-11-23 22:02:09 +0000
116+++ mago/application/firefox.py 2010-12-09 14:59:10 +0000
117@@ -14,6 +14,7 @@
118 from ..cmd import globals
119 import time
120 import gettext
121+import re
122
123 gettext.install (True)
124 gettext.bindtextdomain (PACKAGE, globals.LOCALE_SHARE)
125@@ -29,7 +30,8 @@
126
127 LAUNCHER = 'firefox'
128 LAUNCHER_ARGS = []
129- WINDOW = 'frmMozillaFirefoxStartPage*MozillaFirefox4*0Beta7'
130+ WINDOW = 'frm*MozillaFirefox*'
131+ WINDOW_PATTERN = "frm(.*)-MozillaFirefox.*"
132
133 BTN_17 = _('btn17')
134 BTN_19 = _('btn19')
135@@ -61,8 +63,7 @@
136 MNU_ALLYOURUSERSTUDIES___ = _('mnuAllYourUserStudies***')
137 MNU_BACK = _('mnuBack')
138 MNU_BOOKMARKALLTABS___ = _('mnuBookmarkAllTabs***')
139- MNU_BOOKMARKTHISPAGE = _('mnuBookmarkThisPage')
140- MNU_BOOKMARKTHISPAGE1 = _('mnuBookmarkThisPage1')
141+ MNU_BOOKMARKTHISPAGE = _('mnuBookmarkThisPage*')
142 MNU_CLEARRECENTHISTORY___ = _('mnuClearRecentHistory***')
143 MNU_CLOSETAB = _('mnuCloseTab')
144 MNU_CLOSEWINDOW = _('mnuCloseWindow')
145@@ -125,6 +126,11 @@
146 MNU_WEBSEARCH = _('mnuWebSearch')
147 MNU_ZOOMIN = _('mnuZoomIn')
148 MNU_ZOOMOUT = _('mnuZoomOut')
149+ TXT_AWESOME = _('txtGotoaWebSite')
150+ TXT_SEARCH_GLG = _('txtSearchusingGoogle')
151+ PNL_PAGE_BOOKMARKED = _('pnlPageBookmarked')
152+ BTN_DONE = _('btnDone')
153+ BTN_REMOVE_BOOKMARK = _('btnRemoveBookmark')
154
155
156 def runAboutdialog(self):
157@@ -133,7 +139,7 @@
158 and that the UI reacts
159 The About dialog is the only menu that is always present in the UI
160 """
161- return
162+ return
163
164 # We skip that test for firefox, there no a11y components in the about dialog to play with
165 #
166@@ -169,7 +175,104 @@
167 #
168 # ldtp.click(dlgAbout, btnClose)
169
170-
171 def __init__(self):
172 Application.__init__(self)
173 self.main_window = ooldtp.context(self.WINDOW)
174+
175+ def open_url(self, url):
176+ """
177+ Opens a given URL in Firefox
178+ """
179+ firefox = ooldtp.context(self.WINDOW)
180+ awesome = firefox.getchild(self.TXT_AWESOME)
181+ awesome.settextvalue(url)
182+ ldtp.keypress("<enter>")
183+ ldtp.keyrelease("<enter>")
184+
185+ # Waiting for the page to load
186+ ldtp.wait(5)
187+
188+ def search_google(self, search_text):
189+ """
190+ Searchs in Google, using the search textbox
191+ """
192+ firefox = ooldtp.context(self.WINDOW)
193+ search = firefox.getchild(self.TXT_SEARCH_GLG)
194+ search.settextvalue(search_text)
195+ ldtp.keypress("<enter>")
196+ ldtp.keyrelease("<enter>")
197+
198+ #Waiting for the page to load
199+ ldtp.wait(5)
200+
201+ def get_window_name(self):
202+ """
203+ It returns the name of the navigator at a given point
204+ """
205+ pattern = re.compile(self.WINDOW_PATTERN)
206+
207+ windows = ldtp.getwindowlist()
208+ for win in windows:
209+ match = re.match(pattern, win)
210+ if match:
211+ return match.groups()[0]
212+
213+ def open_new_tab(self):
214+ """
215+ It creates a new tab in Firefox
216+ """
217+ firefox = ooldtp.context(self.WINDOW)
218+ new_tab = firefox.getchild(self.MNU_NEWTAB)
219+ new_tab.click()
220+ firefox.remap()
221+
222+ def close_current_tab(self):
223+ """
224+ It closes the current tab
225+ """
226+ firefox = ooldtp.context(self.WINDOW)
227+ new_tab = firefox.getchild(self.MNU_CLOSETAB)
228+ new_tab.click()
229+ firefox.remap()
230+
231+ def get_tab_names(self):
232+ """
233+ It returns a list with the names of the tabs
234+ """
235+ firefox = ooldtp.context(self.WINDOW)
236+ tabs = firefox.getchild(role="page_tab")
237+ return tabs
238+
239+ def number_of_tabs(self):
240+ """
241+ It returns the number of opened tabs
242+ """
243+ return len(self.get_tab_names())
244+
245+ def add_bookmark(self):
246+ """
247+ It adds the current tab to the bookmarks
248+ """
249+ firefox = ooldtp.context(self.WINDOW)
250+ mnu_add = firefox.getchild(self.MNU_BOOKMARKTHISPAGE)
251+ mnu_add.click()
252+
253+ firefox.remap()
254+ btn_done = firefox.getchild(self.BTN_DONE)
255+ btn_done.mouseleftclick()
256+
257+ def remove_bookmark(self):
258+ """
259+ It removes the current tab to the bookmarks
260+ """
261+ firefox = ooldtp.context(self.WINDOW)
262+ mnu_add = firefox.getchild(self.MNU_BOOKMARKTHISPAGE)
263+ mnu_add.click()
264+
265+ firefox.remap()
266+ btn_remove = firefox.getchild(self.BTN_REMOVE_BOOKMARK)
267+ btn_remove.mouseleftclick()
268+
269+
270+
271+
272
273=== modified file 'mago/test_suite/firefox.py'
274--- mago/test_suite/firefox.py 2010-11-23 22:02:09 +0000
275+++ mago/test_suite/firefox.py 2010-12-09 14:59:10 +0000
276@@ -12,9 +12,12 @@
277 APPLICATION_FACTORY = Firefox
278 def setup(self):
279 self.application.open()
280-
281+
282+ while (self.application.number_of_tabs() > 1):
283+ self.application.close_current_tab()
284+
285 def teardown(self):
286 self.application.close()
287
288 def cleanup(self):
289- self.application.close()
290+ pass

Subscribers

People subscribed via source and target branches

to status/vote changes: