-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathfirst_test.py
More file actions
52 lines (36 loc) · 1.65 KB
/
first_test.py
File metadata and controls
52 lines (36 loc) · 1.65 KB
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
from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
import os, json
config_file_path = os.path.join(os.path.dirname(__file__), "config.json")
print("Path to the config file: %s" % (config_file_path))
with open(config_file_path) as config_file:
CONFIG = json.load(config_file)
BROWSERSTACK_USERNAME = os.environ['BROWSERSTACK_USERNAME'] if 'BROWSERSTACK_USERNAME' in os.environ else CONFIG['username']
BROWSERSTACK_ACCESS_KEY = os.environ['BROWSERSTACK_ACCESS_KEY'] if 'BROWSERSTACK_ACCESS_KEY' in os.environ else CONFIG['access_key']
def test():
"""
Test for BrowserStack sample Wikipedia Android app.
Note: If you have uploaded your app to BrowserStack update the test here.
"""
desired_capabilities = CONFIG['capabilities']
driver = webdriver.Remote(
desired_capabilities = desired_capabilities,
command_executor = "http://%s:%s@%s/wd/hub" % (BROWSERSTACK_USERNAME, BROWSERSTACK_ACCESS_KEY, CONFIG['server'])
)
search_element = WebDriverWait(driver, 30).until (
EC.element_to_be_clickable((MobileBy.ACCESSIBILITY_ID, "Search Wikipedia"))
)
search_element.click()
search_input = WebDriverWait(driver, 30).until (
EC.element_to_be_clickable((MobileBy.ID, "org.wikipedia.alpha:id/search_src_text"))
)
search_input.send_keys("BrowserStack" + "\n")
time.sleep(5)
search_results = driver.find_elements_by_class_name("android.widget.TextView")
assert(len(search_results) > 0)
driver.quit()
if __name__ == "__main__":
test()