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
=== modified file 'firefox/README'
--- firefox/README 2010-11-23 22:02:09 +0000
+++ firefox/README 2010-12-09 14:59:10 +0000
@@ -0,0 +1,19 @@
1BANSHEE TESTS
2=============
3
4Safety
5------
6The tests are safe to run
7
8Configuration
9-------------
10The tests assume that there is a network connection
11
12Available Tests
13---------------
14
15* Open a given URL
16* Search a given text in Google
17* Open a new tab and close it
18* Add a new bookmark and delete it
19
020
=== modified file 'firefox/firefox_basics.py'
--- firefox/firefox_basics.py 2010-11-23 22:02:09 +0000
+++ firefox/firefox_basics.py 2010-12-09 14:59:10 +0000
@@ -5,9 +5,41 @@
5from mago.test_suite.firefox import FirefoxTestSuite 5from mago.test_suite.firefox import FirefoxTestSuite
66
7class FirefoxBasics(FirefoxTestSuite):7class FirefoxBasics(FirefoxTestSuite):
8 def testAboutdialog(self, arg1=None):8
9 self.application.runAboutdialog()9 def testOpenURL(self, url, window_name_oracle):
10 self.application.open_url(url)
11 window_name = self.application.get_window_name()
12
13 if window_name != window_name_oracle:
14 raise AssertionError, "The URL %s was not correctly opened. Window expected: %s, got: %s" % (url, window_name_oracle, window_name)
15
16
17 def testGoogleSearch(self, search_text, window_name_oracle):
18 self.application.search_google(search_text)
19 window_name = self.application.get_window_name()
20 window_name_oracle = search_text + window_name_oracle
21
22 if window_name != window_name_oracle:
23 raise AssertionError, "The Google Search for %s was not correctly opened. Window expected: %s, got: %s" % (search_text, window_name_oracle, window_name)
24
25 def testTabs(self):
26 number_tabs = self.application.number_of_tabs()
27 self.application.open_new_tab()
28 number_tabs_after = self.application.number_of_tabs()
29
30 if (number_tabs + 1) != number_tabs_after:
31 raise AssertionError, "The tab was not created. Number of tabs expected %s, got %s" % (str(number_tabs + 1), str(number_tabs_after))
1032
33 self.application.close_current_tab()
34 number_tabs = self.application.number_of_tabs()
35
36 if (number_tabs + 1) != number_tabs_after:
37 raise AssertionError, "The tab was not created. Number of tabs expected %s, got %s" % (str(number_tabs_after - 1), str(number_tabs))
38
39 def testBookmarks(self):
40 self.application.add_bookmark()
41 self.application.remove_bookmark()
42
11if __name__ == "__main__":43if __name__ == "__main__":
12 firefox_test = FirefoxBasics()44 firefox_test = FirefoxBasics()
13 firefox_test.run()45 firefox_test.run()
1446
=== modified file 'firefox/firefox_basics.xml'
--- firefox/firefox_basics.xml 2010-11-23 22:02:09 +0000
+++ firefox/firefox_basics.xml 2010-12-09 14:59:10 +0000
@@ -4,11 +4,29 @@
4 <description>4 <description>
5 Tests which verify Firefox basics functionality.5 Tests which verify Firefox basics functionality.
6 </description>6 </description>
7 <case name="about_dialog">7 <case name="open_url">
8 <method>testAboutdialog</method>8 <method>testOpenURL</method>
9 <description>Verify that the about dialog launches</description>9 <description>Verify that a particular URL is opened</description>
10 <args>10 <args>
11 <arg1>Arg example</arg1>11 <url>http://www.ubuntu.com</url>
12 </args>12 <window_name_oracle>Ubuntuhomepage|Ubuntu</window_name_oracle>
13 </case>13 </args>
14 </case>
15 <case name="search_google">
16 <method>testGoogleSearch</method>
17 <description>Verify that Google search works correctly</description>
18 <args>
19 <search_text>Ubuntu</search_text>
20 <window_name_oracle>-GoogleSearch</window_name_oracle>
21 </args>
22 </case>
23 <case name="play_with_tabs">
24 <method>testTabs</method>
25 <description>Verify that creation and deletion of tabs works correctly</description>
26 </case>
27 <case name="bookmarks">
28 <method>testBookmarks</method>
29 <description>Verify that creation and deletion of bookmarks works correctly</description>
30 </case>
14</suite>31</suite>
32
1533
=== modified file 'mago/application/firefox.py'
--- mago/application/firefox.py 2010-11-23 22:02:09 +0000
+++ mago/application/firefox.py 2010-12-09 14:59:10 +0000
@@ -14,6 +14,7 @@
14from ..cmd import globals14from ..cmd import globals
15import time15import time
16import gettext16import gettext
17import re
1718
18gettext.install (True)19gettext.install (True)
19gettext.bindtextdomain (PACKAGE, globals.LOCALE_SHARE)20gettext.bindtextdomain (PACKAGE, globals.LOCALE_SHARE)
@@ -29,7 +30,8 @@
2930
30 LAUNCHER = 'firefox'31 LAUNCHER = 'firefox'
31 LAUNCHER_ARGS = []32 LAUNCHER_ARGS = []
32 WINDOW = 'frmMozillaFirefoxStartPage*MozillaFirefox4*0Beta7'33 WINDOW = 'frm*MozillaFirefox*'
34 WINDOW_PATTERN = "frm(.*)-MozillaFirefox.*"
3335
34 BTN_17 = _('btn17')36 BTN_17 = _('btn17')
35 BTN_19 = _('btn19')37 BTN_19 = _('btn19')
@@ -61,8 +63,7 @@
61 MNU_ALLYOURUSERSTUDIES___ = _('mnuAllYourUserStudies***')63 MNU_ALLYOURUSERSTUDIES___ = _('mnuAllYourUserStudies***')
62 MNU_BACK = _('mnuBack')64 MNU_BACK = _('mnuBack')
63 MNU_BOOKMARKALLTABS___ = _('mnuBookmarkAllTabs***')65 MNU_BOOKMARKALLTABS___ = _('mnuBookmarkAllTabs***')
64 MNU_BOOKMARKTHISPAGE = _('mnuBookmarkThisPage')66 MNU_BOOKMARKTHISPAGE = _('mnuBookmarkThisPage*')
65 MNU_BOOKMARKTHISPAGE1 = _('mnuBookmarkThisPage1')
66 MNU_CLEARRECENTHISTORY___ = _('mnuClearRecentHistory***')67 MNU_CLEARRECENTHISTORY___ = _('mnuClearRecentHistory***')
67 MNU_CLOSETAB = _('mnuCloseTab')68 MNU_CLOSETAB = _('mnuCloseTab')
68 MNU_CLOSEWINDOW = _('mnuCloseWindow')69 MNU_CLOSEWINDOW = _('mnuCloseWindow')
@@ -125,6 +126,11 @@
125 MNU_WEBSEARCH = _('mnuWebSearch')126 MNU_WEBSEARCH = _('mnuWebSearch')
126 MNU_ZOOMIN = _('mnuZoomIn')127 MNU_ZOOMIN = _('mnuZoomIn')
127 MNU_ZOOMOUT = _('mnuZoomOut')128 MNU_ZOOMOUT = _('mnuZoomOut')
129 TXT_AWESOME = _('txtGotoaWebSite')
130 TXT_SEARCH_GLG = _('txtSearchusingGoogle')
131 PNL_PAGE_BOOKMARKED = _('pnlPageBookmarked')
132 BTN_DONE = _('btnDone')
133 BTN_REMOVE_BOOKMARK = _('btnRemoveBookmark')
128134
129135
130 def runAboutdialog(self):136 def runAboutdialog(self):
@@ -133,7 +139,7 @@
133 and that the UI reacts139 and that the UI reacts
134 The About dialog is the only menu that is always present in the UI140 The About dialog is the only menu that is always present in the UI
135 """141 """
136 return142 return
137143
138# We skip that test for firefox, there no a11y components in the about dialog to play with144# We skip that test for firefox, there no a11y components in the about dialog to play with
139#145#
@@ -169,7 +175,104 @@
169#175#
170# ldtp.click(dlgAbout, btnClose)176# ldtp.click(dlgAbout, btnClose)
171177
172
173 def __init__(self):178 def __init__(self):
174 Application.__init__(self)179 Application.__init__(self)
175 self.main_window = ooldtp.context(self.WINDOW)180 self.main_window = ooldtp.context(self.WINDOW)
181
182 def open_url(self, url):
183 """
184 Opens a given URL in Firefox
185 """
186 firefox = ooldtp.context(self.WINDOW)
187 awesome = firefox.getchild(self.TXT_AWESOME)
188 awesome.settextvalue(url)
189 ldtp.keypress("<enter>")
190 ldtp.keyrelease("<enter>")
191
192 # Waiting for the page to load
193 ldtp.wait(5)
194
195 def search_google(self, search_text):
196 """
197 Searchs in Google, using the search textbox
198 """
199 firefox = ooldtp.context(self.WINDOW)
200 search = firefox.getchild(self.TXT_SEARCH_GLG)
201 search.settextvalue(search_text)
202 ldtp.keypress("<enter>")
203 ldtp.keyrelease("<enter>")
204
205 #Waiting for the page to load
206 ldtp.wait(5)
207
208 def get_window_name(self):
209 """
210 It returns the name of the navigator at a given point
211 """
212 pattern = re.compile(self.WINDOW_PATTERN)
213
214 windows = ldtp.getwindowlist()
215 for win in windows:
216 match = re.match(pattern, win)
217 if match:
218 return match.groups()[0]
219
220 def open_new_tab(self):
221 """
222 It creates a new tab in Firefox
223 """
224 firefox = ooldtp.context(self.WINDOW)
225 new_tab = firefox.getchild(self.MNU_NEWTAB)
226 new_tab.click()
227 firefox.remap()
228
229 def close_current_tab(self):
230 """
231 It closes the current tab
232 """
233 firefox = ooldtp.context(self.WINDOW)
234 new_tab = firefox.getchild(self.MNU_CLOSETAB)
235 new_tab.click()
236 firefox.remap()
237
238 def get_tab_names(self):
239 """
240 It returns a list with the names of the tabs
241 """
242 firefox = ooldtp.context(self.WINDOW)
243 tabs = firefox.getchild(role="page_tab")
244 return tabs
245
246 def number_of_tabs(self):
247 """
248 It returns the number of opened tabs
249 """
250 return len(self.get_tab_names())
251
252 def add_bookmark(self):
253 """
254 It adds the current tab to the bookmarks
255 """
256 firefox = ooldtp.context(self.WINDOW)
257 mnu_add = firefox.getchild(self.MNU_BOOKMARKTHISPAGE)
258 mnu_add.click()
259
260 firefox.remap()
261 btn_done = firefox.getchild(self.BTN_DONE)
262 btn_done.mouseleftclick()
263
264 def remove_bookmark(self):
265 """
266 It removes the current tab to the bookmarks
267 """
268 firefox = ooldtp.context(self.WINDOW)
269 mnu_add = firefox.getchild(self.MNU_BOOKMARKTHISPAGE)
270 mnu_add.click()
271
272 firefox.remap()
273 btn_remove = firefox.getchild(self.BTN_REMOVE_BOOKMARK)
274 btn_remove.mouseleftclick()
275
276
277
278
176279
=== modified file 'mago/test_suite/firefox.py'
--- mago/test_suite/firefox.py 2010-11-23 22:02:09 +0000
+++ mago/test_suite/firefox.py 2010-12-09 14:59:10 +0000
@@ -12,9 +12,12 @@
12 APPLICATION_FACTORY = Firefox12 APPLICATION_FACTORY = Firefox
13 def setup(self):13 def setup(self):
14 self.application.open()14 self.application.open()
1515
16 while (self.application.number_of_tabs() > 1):
17 self.application.close_current_tab()
18
16 def teardown(self):19 def teardown(self):
17 self.application.close()20 self.application.close()
1821
19 def cleanup(self):22 def cleanup(self):
20 self.application.close()23 pass

Subscribers

People subscribed via source and target branches

to status/vote changes: