-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathget_started.py
More file actions
53 lines (44 loc) · 1.62 KB
/
get_started.py
File metadata and controls
53 lines (44 loc) · 1.62 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
52
53
import sys
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium.webdriver.edge.options import Options as EdgeOptions
from selenium.webdriver.firefox.options import Options as FirefoxOptions
if len(sys.argv) < 2:
print("Usage: python3 get_started.py [chrome|firefox|edge]")
sys.exit(1)
browser = sys.argv[1].lower()
if browser not in ["chrome", "firefox", "edge"]:
print("Unsupported browser. Use 'chrome', 'firefox', or 'edge'.")
sys.exit(1)
if len(sys.argv) > 2:
GRID_URL = sys.argv[2]
else:
GRID_URL = "http://localhost:4444/wd/hub"
import concurrent.futures
def run_browser_instance(browser, grid_url):
options = None
if browser == "chrome":
options = ChromeOptions()
elif browser == "firefox":
options = FirefoxOptions()
elif browser == "edge":
options = EdgeOptions()
options.enable_bidi = True
options.enable_downloads = True
options.set_capability('se:recordVideo', True)
options.set_capability('se:name', "Test this test session")
while True:
driver = webdriver.Remote(
command_executor=grid_url,
options=options,
)
print(f"Session created: {driver.session_id} ({browser})")
driver.get('https://www.google.com/')
print(driver.title)
time.sleep(15)
driver.fire_session_event("test:failed", {"error": "Element not found"})
driver.quit()
with concurrent.futures.ThreadPoolExecutor(max_workers=3) as executor:
for _ in range(3):
executor.submit(run_browser_instance, browser, GRID_URL)