Skip to content

Commit 8deb10c

Browse files
authored
Update battery_test.py
1 parent 6cdc53d commit 8deb10c

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

battery_test.py

+33-5
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,48 @@ def get_browser_path(browser_name):
1818
path = r"C:\Program Files\Mozilla Firefox\firefox.exe"
1919
elif browser_name == "vivaldi":
2020
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+
2130
elif os_name == "Darwin":
2231
if browser_name == "chrome":
2332
path = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
2433
elif browser_name == "firefox":
2534
path = "/Applications/Firefox.app/Contents/MacOS/firefox"
2635
elif browser_name == "vivaldi":
2736
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+
2848
elif os_name == "Linux":
2949
if browser_name == "chrome":
3050
path = "/usr/bin/google-chrome"
3151
elif browser_name == "firefox":
3252
path = "/usr/bin/firefox"
3353
elif browser_name == "vivaldi":
3454
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"
3563

3664
if path and os.path.exists(path):
3765
return path
@@ -54,7 +82,7 @@ def open_browser(browser_path, start_url):
5482
def navigate_to_url(browser_path, url):
5583
"""Navigates the browser to the given URL using subprocess."""
5684
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])
5886
return True
5987
except Exception as e:
6088
print(f"Error navigating to URL: {e}")
@@ -64,7 +92,7 @@ def scroll_and_wait(duration=30):
6492
"""Scrolls up and down for a specified duration."""
6593
start_time = time.time()
6694
while time.time() - start_time < duration:
67-
scroll_amount = random.randint(-2500, 2500)
95+
scroll_amount = random.randint(-500, 500)
6896
pyautogui.scroll(scroll_amount)
6997
time.sleep(0.1)
7098

@@ -79,7 +107,7 @@ def battery_test(website_list, browser_name, start_url):
79107
if not open_browser(browser_path, start_url):
80108
return
81109

82-
time.sleep(5) #Wait for browser to open.
110+
time.sleep(5)
83111

84112
try:
85113
while True:
@@ -128,6 +156,6 @@ def battery_test(website_list, browser_name, start_url):
128156
"https://www.shopify.com",
129157
]
130158

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"
133161
battery_test(website_list, browser_name, start_url)

0 commit comments

Comments
 (0)