-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparallels1.py
More file actions
57 lines (50 loc) · 1.94 KB
/
parallels1.py
File metadata and controls
57 lines (50 loc) · 1.94 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
54
55
56
57
import threading
import time
import requests
from selenium import webdriver
import sys
from requests.auth import HTTPBasicAuth
from time import sleep
import os
num_parallel_threads = 1
def get_chrome_session_logs(session_id):
response = requests.get("https://api.browserstack.com/automate/sessions/{}.json".format(session_id),
auth=HTTPBasicAuth(os.environ['BROWSERSTACK_USERNAME'], os.environ['BROWSERSTACK_ACCESS_KEY']))
browser_console_log_url = response.json(
)["automation_session"]["browser_console_logs_url"]
response2 = requests.get(browser_console_log_url)
print(response2.content)
class AutomateParallelThread(threading.Thread):
def run(self):
desired_cap = {
'os' : 'Windows',
'os_version' : '10',
'browser' : 'Chrome',
'resolution' : '1920x1080',
'browserstack.local' : 'true',
'build' : 'Akhil new',
'browserstack.localIdentifier': os.environ['BROWSERSTACK_LOCAL_IDENTIFIER'],
'browserstack.local' : os.environ['BROWSERSTACK_LOCAL'],
'browserstack.console': 'verbose',
}
hub_url = "http://%s:%s@hub-cloud.browserstack.com:80/wd/hub" % (os.environ['BROWSERSTACK_USERNAME'], os.environ['BROWSERSTACK_ACCESS_KEY'])
driver = webdriver.Remote(
command_executor=hub_url,
desired_capabilities=desired_cap)
# start_time = time.time()
start_time = time.time()
for i in range(20):
driver.get("https://fast.com")
time.sleep(2)
end_time = time.time()
print(driver.session_id)
print("Execution time {}".format(end_time - start_time))
driver.quit()
all_threads = []
for i in range(num_parallel_threads):
automateThread = AutomateParallelThread()
all_threads.append(automateThread)
for thread in all_threads:
thread.start()
for thread in all_threads:
thread.join()