-
Notifications
You must be signed in to change notification settings - Fork 1
/
page_screen_ios.py
66 lines (51 loc) · 1.94 KB
/
page_screen_ios.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
57
58
59
60
61
62
63
64
65
66
import time
from appium.webdriver.common.mobileby import MobileBy
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from config import *
class PageScreen:
def __init__(self, driver):
self.driver = driver
def log_user(self):
login_button = WebDriverWait(self.driver.instance, 15).until(
EC.visibility_of_element_located((
MobileBy.XPATH, "//android.widget.Button"
))
)
login_button.click()
self.switch_context("WEBVIEW_chrome")
self.fill_user_data()
assert 'Logged' in self.verify_user_login()
def switch_context(self, new_context):
#TODO: Search dynamic wait for the context switch
time.sleep(10)
c_context = self.driver.instance.mobile.contexts
# print(c_context)
self.driver.instance.switch_to.context(new_context)
def fill_user_data(self):
username = WebDriverWait(self.driver.instance, 7000).until(
EC.visibility_of_element_located((
MobileBy.XPATH, "//input[@name='username']"
))
)
password = WebDriverWait(self.driver.instance, 2).until(
EC.visibility_of_element_located((
MobileBy.XPATH, "//input[@name='password']"
))
)
username.send_keys(login_user)
password.send_keys(login_password)
button_login = WebDriverWait(self.driver.instance, 2).until(
EC.visibility_of_element_located((
MobileBy.XPATH, "//button[@name='submit']"
))
)
button_login.click()
def verify_user_login(self):
self.switch_context("NATIVE_APP")
logged_text = WebDriverWait(self.driver.instance, 15).until(
EC.visibility_of_element_located((
MobileBy.XPATH, "//android.widget.TextView"
))
)
return logged_text.text