@@ -18,20 +18,48 @@ def get_browser_path(browser_name):
18
18
path = r"C:\Program Files\Mozilla Firefox\firefox.exe"
19
19
elif browser_name == "vivaldi" :
20
20
path = r"C:\Users\YourUserName\AppData\Local\Vivaldi\Application\vivaldi.exe"
21
+ elif browser_name == "edge" :
22
+ path = r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
23
+ elif browser_name == "opera" :
24
+ path = r"C:\Users\YourUserName\AppData\Local\Programs\Opera\opera.exe"
25
+ elif browser_name == "brave" :
26
+ path = r"C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe"
27
+ elif browser_name == "zen" : # example if zen browser is installed on windows
28
+ path = r"C:\Users\YourUserName\AppData\Local\ZenBrowser\Application\zen.exe"
29
+
21
30
elif os_name == "Darwin" :
22
31
if browser_name == "chrome" :
23
32
path = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
24
33
elif browser_name == "firefox" :
25
34
path = "/Applications/Firefox.app/Contents/MacOS/firefox"
26
35
elif browser_name == "vivaldi" :
27
36
path = "/Applications/Vivaldi.app/Contents/MacOS/Vivaldi"
37
+ elif browser_name == "edge" :
38
+ path = "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
39
+ elif browser_name == "opera" :
40
+ path = "/Applications/Opera.app/Contents/MacOS/Opera"
41
+ elif browser_name == "brave" :
42
+ path = "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
43
+ elif browser_name == "safari" :
44
+ path = "/Applications/Safari.app/Contents/MacOS/Safari"
45
+ elif browser_name == "zen" : #example if zen browser is installed on MacOS
46
+ path = "/Applications/ZenBrowser.app/Contents/MacOS/ZenBrowser"
47
+
28
48
elif os_name == "Linux" :
29
49
if browser_name == "chrome" :
30
50
path = "/usr/bin/google-chrome"
31
51
elif browser_name == "firefox" :
32
52
path = "/usr/bin/firefox"
33
53
elif browser_name == "vivaldi" :
34
54
path = "/usr/bin/vivaldi"
55
+ elif browser_name == "edge" :
56
+ path = "/usr/bin/microsoft-edge"
57
+ elif browser_name == "opera" :
58
+ path = "/usr/bin/opera"
59
+ elif browser_name == "brave" :
60
+ path = "/usr/bin/brave-browser"
61
+ elif browser_name == "zen" : #example if zen browser is installed on linux.
62
+ path = "/usr/bin/zenbrowser"
35
63
36
64
if path and os .path .exists (path ):
37
65
return path
@@ -54,7 +82,7 @@ def open_browser(browser_path, start_url):
54
82
def navigate_to_url (browser_path , url ):
55
83
"""Navigates the browser to the given URL using subprocess."""
56
84
try :
57
- subprocess .Popen ([browser_path , "--remote-debugging-port=9222" , "--remote-debugging-address=127.0.0.1" , url ]) #this will open a new instance of the browser if one isn't already open.
85
+ subprocess .Popen ([browser_path , "--remote-debugging-port=9222" , "--remote-debugging-address=127.0.0.1" , url ])
58
86
return True
59
87
except Exception as e :
60
88
print (f"Error navigating to URL: { e } " )
@@ -64,7 +92,7 @@ def scroll_and_wait(duration=30):
64
92
"""Scrolls up and down for a specified duration."""
65
93
start_time = time .time ()
66
94
while time .time () - start_time < duration :
67
- scroll_amount = random .randint (- 2500 , 2500 )
95
+ scroll_amount = random .randint (- 500 , 500 )
68
96
pyautogui .scroll (scroll_amount )
69
97
time .sleep (0.1 )
70
98
@@ -79,7 +107,7 @@ def battery_test(website_list, browser_name, start_url):
79
107
if not open_browser (browser_path , start_url ):
80
108
return
81
109
82
- time .sleep (5 ) #Wait for browser to open.
110
+ time .sleep (5 )
83
111
84
112
try :
85
113
while True :
@@ -128,6 +156,6 @@ def battery_test(website_list, browser_name, start_url):
128
156
"https://www.shopify.com" ,
129
157
]
130
158
131
- browser_name = input ("Enter the name of the browser you want to test (chrome, firefox, vivaldi or another): " ).lower ()
132
- start_url = "about:blank" # Open a blank page first.
159
+ browser_name = input ("Enter the name of the browser you want to test (chrome, firefox, vivaldi, edge, opera, brave, safari, zen or another): " ).lower ()
160
+ start_url = "about:blank"
133
161
battery_test (website_list , browser_name , start_url )
0 commit comments