Skip to content

Commit d0a26b8

Browse files
authored
Merge pull request #3770 from seleniumbase/refresh-dependencies-and-refactor-2
Refresh dependencies and refactor code
2 parents 1ba20cd + 8e83900 commit d0a26b8

25 files changed

+42
-95
lines changed

examples/cdp_mode/raw_async.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ async def main():
1616
time.sleep(1)
1717
await element.send_keys_async("Boston")
1818
time.sleep(2)
19+
driver.stop()
1920

2021
if __name__ == "__main__":
2122
# Call an async function with awaited methods
@@ -39,6 +40,7 @@ async def main():
3940
time.sleep(2)
4041
print(loop.run_until_complete(page.evaluate("document.title")))
4142
time.sleep(1)
43+
driver.stop()
4244

4345
# Call CDP methods via the simplified SB CDP API
4446
sb = sb_cdp.Chrome("https://www.priceline.com/")
@@ -62,3 +64,4 @@ async def main():
6264
cards = sb.select_all('span[data-automation*="product-list-card"]')
6365
for card in cards:
6466
print("* %s" % card.text)
67+
sb.driver.stop()

examples/cdp_mode/raw_cdp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def main():
3030
cards = sb.select_all('span[data-automation*="product-list-card"]')
3131
for card in cards:
3232
print("* %s" % card.text)
33+
sb.driver.stop()
3334

3435

3536
if __name__ == "__main__":

examples/cdp_mode/raw_cdp_extended.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
sb.gui_drag_and_drop("img#logo", "div#drop2")
2222
sb.nested_click("iframe#myFrame3", ".fBox")
2323
sb.sleep(2)
24+
sb.driver.stop()

examples/cdp_mode/raw_cdp_nike.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
print('**** Found results for "%s": ****' % search)
1313
for element in elements:
1414
print("* " + element.text)
15+
sb.driver.stop()

examples/cdp_mode/raw_cookies_async.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async def get_login_cookies():
1616
element = await page.select('input[type="submit"]')
1717
await element.click_async()
1818
cookies = await driver.cookies.get_all()
19-
await page.close()
19+
driver.stop()
2020
return cookies
2121

2222

@@ -30,6 +30,7 @@ async def login_with_cookies(cookies):
3030
await driver.get(url_2)
3131
await page.select("div.inventory_list")
3232
time.sleep(2)
33+
driver.stop()
3334

3435

3536
if __name__ == "__main__":

examples/cdp_mode/raw_geolocation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def main():
1111
sb.click('a[aria-label="Show My Location"]')
1212
sb.assert_url_contains("48.876450/2.263400")
1313
sb.sleep(5)
14+
sb.driver.stop()
1415

1516

1617
if __name__ == "__main__":

examples/cdp_mode/raw_multi_async.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ async def main(url):
1515
button = await page.select("button")
1616
await button.click_async()
1717
await page.sleep(2)
18+
driver.stop()
1819

1920

2021
def set_up_loop(url):

examples/cdp_mode/raw_proxy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def main():
4444
data.append(row.strip())
4545
print("\n".join(data).replace('\n"', ' "'))
4646
sb.sleep(3)
47+
sb.driver.stop()
4748

4849

4950
if __name__ == "__main__":

examples/cdp_mode/raw_req_async.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ async def start_test(self):
3636
url = "https://gettyimages.com/photos/firefly-2003-nathan"
3737
await driver.get(url)
3838
await asyncio.sleep(5)
39+
driver.stop()
3940

4041

4142
@decorators.print_runtime("RequestPausedTest")

examples/cdp_mode/raw_timezone.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def main():
2828
sb.remove_elements("#right-sidebar")
2929
sb.remove_elements('[id*="Footer"]')
3030
sb.sleep(6)
31+
sb.driver.stop()
3132

3233

3334
if __name__ == "__main__":

help_docs/syntax_formats.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,7 @@ async def main():
10331033
time.sleep(1)
10341034
await element.send_keys_async("Boston")
10351035
time.sleep(2)
1036+
driver.stop()
10361037

10371038
if __name__ == "__main__":
10381039
loop = asyncio.new_event_loop()
@@ -1075,6 +1076,7 @@ def main():
10751076
cards = sb.select_all('span[data-automation*="product-list-card"]')
10761077
for card in cards:
10771078
print("* %s" % card.text)
1079+
sb.driver.stop()
10781080

10791081

10801082
if __name__ == "__main__":

requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ trio-websocket==0.12.2
4545
wsproto==1.2.0
4646
websocket-client==1.8.0
4747
selenium==4.27.1;python_version<"3.9"
48-
selenium==4.32.0;python_version>="3.9"
48+
selenium==4.32.0;python_version>="3.9" and python_version<"3.10"
49+
selenium==4.33.0;python_version>="3.10"
4950
cssselect==1.2.0;python_version<"3.9"
5051
cssselect==1.3.0;python_version>="3.9"
5152
sortedcontainers==2.4.0
@@ -74,7 +75,7 @@ rich>=14.0.0,<15
7475
# ("pip install -r requirements.txt" also installs this, but "pip install -e ." won't.)
7576

7677
coverage>=7.6.1;python_version<"3.9"
77-
coverage>=7.8.1;python_version>="3.9"
78+
coverage>=7.8.2;python_version>="3.9"
7879
pytest-cov>=5.0.0;python_version<"3.9"
7980
pytest-cov>=6.1.1;python_version>="3.9"
8081
flake8==5.0.4;python_version<"3.9"

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.38.3"
2+
__version__ = "4.39.0"

seleniumbase/behave/behave_sb.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,15 +1280,9 @@ def _perform_behave_unconfigure_():
12801280
)
12811281
find_it_3 = '<td class="col-result">Untested</td>'
12821282
swap_with_3 = '<td class="col-result">Unreported</td>'
1283-
if sys.version_info[0] >= 3:
1284-
# These use caching to prevent extra method calls
1285-
DASH_PIE_PNG_1 = constants.Dashboard.get_dash_pie_1()
1286-
DASH_PIE_PNG_2 = constants.Dashboard.get_dash_pie_2()
1287-
else:
1288-
from seleniumbase.core import encoded_images
1289-
1290-
DASH_PIE_PNG_1 = encoded_images.get_dash_pie_png1()
1291-
DASH_PIE_PNG_2 = encoded_images.get_dash_pie_png2()
1283+
# These use caching to prevent extra method calls
1284+
DASH_PIE_PNG_1 = constants.Dashboard.get_dash_pie_1()
1285+
DASH_PIE_PNG_2 = constants.Dashboard.get_dash_pie_2()
12921286
find_it_4 = 'href="%s"' % DASH_PIE_PNG_1
12931287
swap_with_4 = 'href="%s"' % DASH_PIE_PNG_2
12941288
try:

seleniumbase/console_scripts/run.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,6 @@ def main():
10011001
retry_msg_2 = "** Unable to download driver! Retrying in 5s..."
10021002
if " --proxy=" in " ".join(sys.argv):
10031003
from seleniumbase.core import proxy_helper
1004-
10051004
for arg in sys.argv:
10061005
if arg.startswith("--proxy="):
10071006
proxy_string = arg.split("--proxy=")[1]
@@ -1036,26 +1035,22 @@ def main():
10361035
show_install_usage()
10371036
elif command == "commander" or command == "gui":
10381037
from seleniumbase.console_scripts import sb_commander
1039-
10401038
sb_commander.main()
10411039
elif command == "behave-gui" or command == "gui-behave":
10421040
from seleniumbase.console_scripts import sb_behave_gui
1043-
10441041
sb_behave_gui.main()
10451042
elif (
10461043
command == "caseplans"
10471044
or command == "case-plans"
10481045
or command == "case_plans"
10491046
):
10501047
from seleniumbase.console_scripts import sb_caseplans
1051-
10521048
sb_caseplans.main()
10531049
elif (
10541050
command == "recorder"
10551051
or (command == "record" and len(command_args) == 0)
10561052
):
10571053
from seleniumbase.console_scripts import sb_recorder
1058-
10591054
sb_recorder.main()
10601055
elif (
10611056
command == "mkrec"
@@ -1064,7 +1059,6 @@ def main():
10641059
):
10651060
if len(command_args) >= 1:
10661061
from seleniumbase.console_scripts import sb_mkrec
1067-
10681062
sb_mkrec.main()
10691063
else:
10701064
show_basic_usage()
@@ -1075,70 +1069,55 @@ def main():
10751069
elif command == "mkdir":
10761070
if len(command_args) >= 1:
10771071
from seleniumbase.console_scripts import sb_mkdir
1078-
10791072
sb_mkdir.main()
10801073
else:
10811074
show_basic_usage()
10821075
show_mkdir_usage()
10831076
elif command == "mkfile":
10841077
if len(command_args) >= 1:
10851078
from seleniumbase.console_scripts import sb_mkfile
1086-
10871079
sb_mkfile.main()
10881080
else:
10891081
show_basic_usage()
10901082
show_mkfile_usage()
10911083
elif command == "mkpres":
10921084
if len(command_args) >= 1:
10931085
from seleniumbase.console_scripts import sb_mkpres
1094-
10951086
sb_mkpres.main()
10961087
else:
10971088
show_basic_usage()
10981089
show_mkpres_usage()
10991090
elif command == "mkchart":
11001091
if len(command_args) >= 1:
11011092
from seleniumbase.console_scripts import sb_mkchart
1102-
11031093
sb_mkchart.main()
11041094
else:
11051095
show_basic_usage()
11061096
show_mkchart_usage()
11071097
elif command == "convert":
11081098
if len(command_args) == 1:
11091099
from seleniumbase.utilities.selenium_ide import convert_ide
1110-
11111100
convert_ide.main()
11121101
else:
11131102
show_basic_usage()
11141103
show_convert_usage()
11151104
elif command == "print":
11161105
if len(command_args) >= 1:
11171106
from seleniumbase.console_scripts import sb_print
1118-
11191107
sb_print.main()
11201108
else:
11211109
show_basic_usage()
11221110
show_print_usage()
11231111
elif command == "translate":
11241112
if len(command_args) >= 1:
1125-
if sys.version_info[0] == 2:
1126-
c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
1127-
cr = colorama.Style.RESET_ALL
1128-
msg = "The SeleniumBase Translator does NOT support Python 2!"
1129-
message = "\n" + c5 + msg + cr + "\n"
1130-
print("")
1131-
raise Exception(message)
11321113
from seleniumbase.translate import translator
1133-
11341114
translator.main()
11351115
else:
11361116
show_basic_usage()
11371117
show_translate_usage()
11381118
elif command == "extract-objects" or command == "extract_objects":
11391119
if len(command_args) >= 1:
11401120
from seleniumbase.console_scripts import sb_objectify
1141-
11421121
sb_objectify.extract_objects()
11431122
else:
11441123
show_basic_usage()
@@ -1154,31 +1133,27 @@ def main():
11541133
elif command == "objectify":
11551134
if len(command_args) >= 1:
11561135
from seleniumbase.console_scripts import sb_objectify
1157-
11581136
sb_objectify.objectify()
11591137
else:
11601138
show_basic_usage()
11611139
show_objectify_usage()
11621140
elif command == "revert-objects" or command == "revert_objects":
11631141
if len(command_args) >= 1:
11641142
from seleniumbase.console_scripts import sb_objectify
1165-
11661143
sb_objectify.revert_objects()
11671144
else:
11681145
show_basic_usage()
11691146
show_revert_objects_usage()
11701147
elif command == "encrypt" or command == "obfuscate":
11711148
if len(command_args) >= 0:
11721149
from seleniumbase.common import obfuscate
1173-
11741150
obfuscate.main()
11751151
else:
11761152
show_basic_usage()
11771153
show_encrypt_usage()
11781154
elif command == "decrypt" or command == "unobfuscate":
11791155
if len(command_args) >= 0:
11801156
from seleniumbase.common import unobfuscate
1181-
11821157
unobfuscate.main()
11831158
else:
11841159
show_basic_usage()
@@ -1188,31 +1163,27 @@ def main():
11881163
from seleniumbase.utilities.selenium_grid import (
11891164
download_selenium_server,
11901165
)
1191-
11921166
download_selenium_server.main(force_download=True)
11931167
else:
11941168
show_basic_usage()
11951169
show_download_usage()
11961170
elif command == "grid-hub" or command == "grid_hub":
11971171
if len(command_args) >= 1:
11981172
from seleniumbase.utilities.selenium_grid import grid_hub
1199-
12001173
grid_hub.main()
12011174
else:
12021175
show_basic_usage()
12031176
show_grid_hub_usage()
12041177
elif command == "grid-node" or command == "grid_node":
12051178
if len(command_args) >= 1:
12061179
from seleniumbase.utilities.selenium_grid import grid_node
1207-
12081180
grid_node.main()
12091181
else:
12101182
show_basic_usage()
12111183
show_grid_node_usage()
12121184
elif command == "version" or command == "--version" or command == "-v":
12131185
if len(command_args) == 0:
12141186
from seleniumbase.console_scripts import logo_helper
1215-
12161187
seleniumbase_logo = logo_helper.get_seleniumbase_logo()
12171188
print(seleniumbase_logo)
12181189
print("")
@@ -1231,7 +1202,6 @@ def main():
12311202
import fasteners
12321203
import os
12331204
import warnings
1234-
12351205
with warnings.catch_warnings():
12361206
warnings.simplefilter("ignore", category=UserWarning)
12371207
pip_find_lock = fasteners.InterProcessLock(

seleniumbase/console_scripts/sb_behave_gui.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@
2020
from seleniumbase.fixtures import shared_utils
2121
from tkinter.scrolledtext import ScrolledText
2222

23-
if sys.version_info <= (3, 8):
24-
current_version = ".".join(str(ver) for ver in sys.version_info[:3])
25-
raise Exception(
26-
"\n* SBase Commander requires Python 3.8 or newer!"
27-
"\n** You are currently using Python %s" % current_version
28-
)
29-
3023

3124
def set_colors(use_colors):
3225
c0 = ""

seleniumbase/console_scripts/sb_caseplans.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@
2525
from tkinter import messagebox
2626
from tkinter.scrolledtext import ScrolledText
2727

28-
if sys.version_info <= (3, 8):
29-
current_version = ".".join(str(ver) for ver in sys.version_info[:3])
30-
raise Exception(
31-
"\n* SBase Case Plans Generator requires Python 3.8 or newer!"
32-
"\n** You are currently using Python %s" % current_version
33-
)
34-
3528

3629
def set_colors(use_colors):
3730
c0 = ""

seleniumbase/console_scripts/sb_commander.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@
2525
from seleniumbase.fixtures import shared_utils
2626
from tkinter.scrolledtext import ScrolledText
2727

28-
if sys.version_info <= (3, 8):
29-
current_version = ".".join(str(ver) for ver in sys.version_info[:3])
30-
raise Exception(
31-
"\n* SBase Commander requires Python 3.8 or newer!"
32-
"\n** You are currently using Python %s" % current_version
33-
)
34-
3528

3629
def set_colors(use_colors):
3730
c0 = ""

seleniumbase/console_scripts/sb_recorder.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@
3030
sys_executable = sys.executable
3131
if " " in sys_executable:
3232
sys_executable = "python"
33-
if sys.version_info <= (3, 8):
34-
current_version = ".".join(str(ver) for ver in sys.version_info[:3])
35-
raise Exception(
36-
"\n* Recorder Desktop requires Python 3.8 or newer!"
37-
"\n*** You are currently using Python %s" % current_version
38-
)
3933

4034

4135
def set_colors(use_colors):

0 commit comments

Comments
 (0)