forked from mozilla/input-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage.py
36 lines (27 loc) · 1.11 KB
/
page.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
#!/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.support.ui import WebDriverWait
from unittestzero import Assert
class Page(object):
def __init__(self, testsetup):
self.testsetup = testsetup
self.base_url = testsetup.base_url
self.selenium = testsetup.selenium
self.timeout = testsetup.timeout
@property
def is_the_current_page(self):
if self._page_title:
WebDriverWait(self.selenium, self.timeout).until(lambda s: s.title)
Assert.equal(self.selenium.title, self._page_title,
"Expected page title: %s. Actual page title: %s" % (self._page_title, self.selenium.title))
return True
def is_element_visible(self, locator):
try:
return self.selenium.find_element(*locator).is_displayed()
except:
return False
@property
def current_page_url(self):
return(self.selenium.current_url)