forked from Beit-Hatfutsot/dbs-front
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowserstack.py
executable file
·24 lines (19 loc) · 1.03 KB
/
browserstack.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
#!/usr/bin/env python
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import os, json
# you need to set the following environment variables prior to running:
# SEL_CAP={\"browser\":\"Edge\",\"browser_version\":\"15.0\",\"os\":\"Windows\",\"os_version\":\"10\",\"resolution\":\"1280x1024\"}
# SEL_EXEC=http://username:[email protected]:80/wd/hub
# SEL_URLS=http://test.dbs.bh.org.il/,http://test.dbs.bh.org.il/search?q=Cohen,http://test.dbs.bh.org.il/familyname/cohen
# SEL_TITLE=Edge-15-Win-10
desired_cap = json.loads(os.environ["SEL_CAP"])
driver = webdriver.Remote(command_executor=os.environ["SEL_EXEC"], desired_capabilities=desired_cap)
for i, url in enumerate(os.environ["SEL_URLS"].split(",")):
filename="screenshot-{}-{}.png".format(os.environ["SEL_TITLE"], i)
print("saving {} from url {}".format(filename, url))
driver.get(url)
driver.maximize_window()
driver.save_screenshot(filename)
driver.quit()