Skip to content

Commit

Permalink
Cleaned up myapps_page.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmith committed Jan 20, 2012
1 parent 37e8b4a commit 7f8538c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 20 deletions.
60 changes: 41 additions & 19 deletions lib/myapps_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,52 @@
Date: 1/18/2012
"""

class ApplicationNotFoundError(Exception):
"""
Thrown to indicate that the application image specified was not found.
"""
pass


class MyAppsPage:
""" MyApps class creates a page object model """
"""
Represents the My Applications Web Page at the below URL specified
in the constant. Allows callers to delete applications.
"""
URL = "https://myapps.mozillalabs.com/"
CLICK_TO_LAUNCH_IMG = "clicktolaunch.png"
UNINSTALL_OK_IMG = "uninstall_ok.png"

def __init__(self, app):
""" initialize the myapp object """
self.system = ConstructOSBox()
def __init__(self):
"""
Constructs a MyAppsPage object.
"""
self._system = ConstructOSBox()

def page_loaded(self):
"""Reloads the dashboard """
wait(self.system.images("clicktolaunch.png"), 10)
"""
Waits for the MyAppsPage to be loaded.
"""
wait(self._system.images(MyAppsPage.CLICK_TO_LAUNCH_IMG))

def delete(self, appimage):
""" delete an app from the myapps page """
self.go()
"""
Deletes the specified application specified in the image.
Arguments:
appimage: The image of the application to delete
Throws:
ApplicationNotFoundError if the application image specified
is not found
"""
self.page_loaded()
found = find(appimage)
uninstall_visible = 0
hover(found)
mouseDown(Button.LEFT)
wait(2)
mouseUp()
click(self.system.images("uninstall_ok.png"))

def go(self):
""" launches the dashboard, through the icon in the bottom right of firefox """
click(self.system.images("dashboard_launcher.png"))

if(exists(appimage)):
hover(find(appimage))
mouseDown(Button.LEFT)
wait(2)
mouseUp()
click(self._system.images(MyAppsPage.UNINSTALL_OK_IMG))
else:
raise ApplicationNotFoundError(str(appimage) + " was not found.")
2 changes: 1 addition & 1 deletion tests/basic_install_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def setUp(self):

self.appdir = AppDirPage()
self.appdir.page_loaded()
self.myapps = MyAppsPage(self.firefox)
self.myapps = MyAppsPage()

self.installable = self.appdir.installable_apps()
self.installed = self.appdir.installed_apps()
Expand Down

0 comments on commit 7f8538c

Please sign in to comment.