This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
collections.py
56 lines (40 loc) · 2.15 KB
/
collections.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from marionette.by import By
from marionette.marionette import Actions
from gaiatest.apps.base import Base
from gaiatest.apps.base import PageRegion
from gaiatest.apps.homescreen.regions.bookmark_menu import BookmarkMenu
class Collection(Base):
_apps_locator = (By.CSS_SELECTOR, '.evme-apps ul.cloud li[data-name]')
_homescreen_status_notification = (By.CSS_SELECTOR, "section[role='status'] > p")
def wait_for_collection_screen_visible(self):
self.wait_for_element_displayed(*self._apps_locator)
@property
def notification_message(self):
self.wait_for_element_displayed(*self._homescreen_status_notification)
return self.marionette.find_element(*self._homescreen_status_notification).text
@property
def applications(self):
return [self.Result(self.marionette, app) for app in self.marionette.find_elements(*self._apps_locator)]
class Result(PageRegion):
# Modal dialog locators
_modal_dialog_save_locator = (By.CSS_SELECTOR, ".cloud-app-actions.show > menu > button[data-action = 'save']")
@property
def name(self):
return self.root_element.get_attribute('data-name')
def tap(self):
app_name = self.name
self.root_element.tap()
# Wait for the displayed app to be that we have tapped
self.wait_for_condition(lambda m: self.apps.displayed_app.name == app_name)
self.apps.switch_to_displayed_app()
# Wait for title to load (we cannot be more specific because the aut may change)
self.wait_for_condition(lambda m: m.title)
def long_tap_to_install(self):
Actions(self.marionette).long_press(self.root_element, 2).perform()
def tap_save_to_home_screen(self):
self.wait_for_element_displayed(*self._modal_dialog_save_locator)
self.marionette.find_element(*self._modal_dialog_save_locator).tap()
return BookmarkMenu(self.marionette)