-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathtest.py
More file actions
46 lines (36 loc) · 1.33 KB
/
test.py
File metadata and controls
46 lines (36 loc) · 1.33 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
from selenium import webdriver
import os, sys, json
try:
json_name = sys.argv[1]
counter_val = sys.argv[2]
except IndexError:
print('Json name and counter val must be passed as first and second argument, respectively, from the comamnd line')
sys.exit(1)
USERNAME = os.environ.get('BROWSERSTACK_USERNAME') or sys.argv[2]
BROWSERSTACK_ACCESS_KEY = os.environ.get('BROWSERSTACK_ACCESS_KEY') or sys.argv[3]
with open(json_name, "r") as f:
obj = json.loads(f.read())
instance_caps = obj[int(counter_val)]
print("Test %s started" % (counter_val))
#------------------------------------------------------#
# Mention any other capabilities required in the test
caps = {}
caps["browserstack.debug"] = "true"
caps["build"] = "parallel tests"
#------------------------------------------------------#
caps = {**caps, **instance_caps}
#------------------------------------------------------#
# THE TEST TO BE RUN PARALLELY GOES HERE
driver = webdriver.Remote(
USERNAME, BROWSERSTACK_ACCESS_KEY
),
desired_capabilities=caps
)
driver.get("http://www.google.com")
inputElement = driver.find_element_by_name("q")
inputElement.send_keys("browserstack")
inputElement.submit()
print(driver.title)
driver.quit()
#------------------------------------------------------#