This repository has been archived by the owner on Aug 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
/
base.py
46 lines (31 loc) · 1.52 KB
/
base.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
#!/usr/bin/env python
# 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 selenium.webdriver.common.by import By
from pages.page import Page
class Base(Page):
@property
def header(self):
return Base.HeaderRegion(self.testsetup)
class HeaderRegion(Page):
_dropdown_expanded_menu_locator = (By.CSS_SELECTOR, 'div.moz-menu')
_menu_items_locator = (By.CSS_SELECTOR, '.menu-items li')
_menu_button_locator = (By.CSS_SELECTOR, '.tab > a')
def click_header_menu(self):
self.selenium.find_element(*self._menu_button_locator).click()
@property
def is_dropdown_menu_expanded(self):
return "expand" in self.selenium.find_element(*self._dropdown_expanded_menu_locator).get_attribute('class')
@property
def dropdown_menu_items(self):
#returns a list containing all the menu items
return [self.MenuItem(self.testsetup, web_element) for web_element in self.selenium.find_elements(*self._menu_items_locator)]
class MenuItem(Page):
_name_items_locator = (By.CSS_SELECTOR, 'a')
def __init__(self, testsetup, element):
Page.__init__(self, testsetup)
self._root_element = element
@property
def name(self):
return self._root_element.find_element(*self._name_items_locator).text