Skip to content

Refresh dependencies and refactor (alpha) #3769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/cdp_mode/raw_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ async def main():
time.sleep(1)
await element.send_keys_async("Boston")
time.sleep(2)
driver.stop()

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

# Call CDP methods via the simplified SB CDP API
sb = sb_cdp.Chrome("https://www.priceline.com/")
Expand All @@ -62,3 +64,4 @@ async def main():
cards = sb.select_all('span[data-automation*="product-list-card"]')
for card in cards:
print("* %s" % card.text)
sb.driver.stop()
1 change: 1 addition & 0 deletions examples/cdp_mode/raw_cdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def main():
cards = sb.select_all('span[data-automation*="product-list-card"]')
for card in cards:
print("* %s" % card.text)
sb.driver.stop()


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions examples/cdp_mode/raw_cdp_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
sb.gui_drag_and_drop("img#logo", "div#drop2")
sb.nested_click("iframe#myFrame3", ".fBox")
sb.sleep(2)
sb.driver.stop()
1 change: 1 addition & 0 deletions examples/cdp_mode/raw_cdp_nike.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
print('**** Found results for "%s": ****' % search)
for element in elements:
print("* " + element.text)
sb.driver.stop()
3 changes: 2 additions & 1 deletion examples/cdp_mode/raw_cookies_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async def get_login_cookies():
element = await page.select('input[type="submit"]')
await element.click_async()
cookies = await driver.cookies.get_all()
await page.close()
driver.stop()
return cookies


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


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions examples/cdp_mode/raw_geolocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def main():
sb.click('a[aria-label="Show My Location"]')
sb.assert_url_contains("48.876450/2.263400")
sb.sleep(5)
sb.driver.stop()


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions examples/cdp_mode/raw_multi_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ async def main(url):
button = await page.select("button")
await button.click_async()
await page.sleep(2)
driver.stop()


def set_up_loop(url):
Expand Down
1 change: 1 addition & 0 deletions examples/cdp_mode/raw_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def main():
data.append(row.strip())
print("\n".join(data).replace('\n"', ' "'))
sb.sleep(3)
sb.driver.stop()


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions examples/cdp_mode/raw_req_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ async def start_test(self):
url = "https://gettyimages.com/photos/firefly-2003-nathan"
await driver.get(url)
await asyncio.sleep(5)
driver.stop()


@decorators.print_runtime("RequestPausedTest")
Expand Down
1 change: 1 addition & 0 deletions examples/cdp_mode/raw_timezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def main():
sb.remove_elements("#right-sidebar")
sb.remove_elements('[id*="Footer"]')
sb.sleep(6)
sb.driver.stop()


if __name__ == "__main__":
Expand Down
2 changes: 2 additions & 0 deletions help_docs/syntax_formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,7 @@ async def main():
time.sleep(1)
await element.send_keys_async("Boston")
time.sleep(2)
driver.stop()

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


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ trio-websocket==0.12.2
wsproto==1.2.0
websocket-client==1.8.0
selenium==4.27.1;python_version<"3.9"
selenium==4.32.0;python_version>="3.9"
selenium==4.33.0;python_version>="3.9"
cssselect==1.2.0;python_version<"3.9"
cssselect==1.3.0;python_version>="3.9"
sortedcontainers==2.4.0
Expand Down Expand Up @@ -74,7 +74,7 @@ rich>=14.0.0,<15
# ("pip install -r requirements.txt" also installs this, but "pip install -e ." won't.)

coverage>=7.6.1;python_version<"3.9"
coverage>=7.8.1;python_version>="3.9"
coverage>=7.8.2;python_version>="3.9"
pytest-cov>=5.0.0;python_version<"3.9"
pytest-cov>=6.1.1;python_version>="3.9"
flake8==5.0.4;python_version<"3.9"
Expand Down
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "4.38.3"
__version__ = "4.39.0"
12 changes: 3 additions & 9 deletions seleniumbase/behave/behave_sb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1280,15 +1280,9 @@ def _perform_behave_unconfigure_():
)
find_it_3 = '<td class="col-result">Untested</td>'
swap_with_3 = '<td class="col-result">Unreported</td>'
if sys.version_info[0] >= 3:
# These use caching to prevent extra method calls
DASH_PIE_PNG_1 = constants.Dashboard.get_dash_pie_1()
DASH_PIE_PNG_2 = constants.Dashboard.get_dash_pie_2()
else:
from seleniumbase.core import encoded_images

DASH_PIE_PNG_1 = encoded_images.get_dash_pie_png1()
DASH_PIE_PNG_2 = encoded_images.get_dash_pie_png2()
# These use caching to prevent extra method calls
DASH_PIE_PNG_1 = constants.Dashboard.get_dash_pie_1()
DASH_PIE_PNG_2 = constants.Dashboard.get_dash_pie_2()
find_it_4 = 'href="%s"' % DASH_PIE_PNG_1
swap_with_4 = 'href="%s"' % DASH_PIE_PNG_2
try:
Expand Down
30 changes: 0 additions & 30 deletions seleniumbase/console_scripts/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,6 @@ def main():
retry_msg_2 = "** Unable to download driver! Retrying in 5s..."
if " --proxy=" in " ".join(sys.argv):
from seleniumbase.core import proxy_helper

for arg in sys.argv:
if arg.startswith("--proxy="):
proxy_string = arg.split("--proxy=")[1]
Expand Down Expand Up @@ -1036,26 +1035,22 @@ def main():
show_install_usage()
elif command == "commander" or command == "gui":
from seleniumbase.console_scripts import sb_commander

sb_commander.main()
elif command == "behave-gui" or command == "gui-behave":
from seleniumbase.console_scripts import sb_behave_gui

sb_behave_gui.main()
elif (
command == "caseplans"
or command == "case-plans"
or command == "case_plans"
):
from seleniumbase.console_scripts import sb_caseplans

sb_caseplans.main()
elif (
command == "recorder"
or (command == "record" and len(command_args) == 0)
):
from seleniumbase.console_scripts import sb_recorder

sb_recorder.main()
elif (
command == "mkrec"
Expand All @@ -1064,7 +1059,6 @@ def main():
):
if len(command_args) >= 1:
from seleniumbase.console_scripts import sb_mkrec

sb_mkrec.main()
else:
show_basic_usage()
Expand All @@ -1075,70 +1069,55 @@ def main():
elif command == "mkdir":
if len(command_args) >= 1:
from seleniumbase.console_scripts import sb_mkdir

sb_mkdir.main()
else:
show_basic_usage()
show_mkdir_usage()
elif command == "mkfile":
if len(command_args) >= 1:
from seleniumbase.console_scripts import sb_mkfile

sb_mkfile.main()
else:
show_basic_usage()
show_mkfile_usage()
elif command == "mkpres":
if len(command_args) >= 1:
from seleniumbase.console_scripts import sb_mkpres

sb_mkpres.main()
else:
show_basic_usage()
show_mkpres_usage()
elif command == "mkchart":
if len(command_args) >= 1:
from seleniumbase.console_scripts import sb_mkchart

sb_mkchart.main()
else:
show_basic_usage()
show_mkchart_usage()
elif command == "convert":
if len(command_args) == 1:
from seleniumbase.utilities.selenium_ide import convert_ide

convert_ide.main()
else:
show_basic_usage()
show_convert_usage()
elif command == "print":
if len(command_args) >= 1:
from seleniumbase.console_scripts import sb_print

sb_print.main()
else:
show_basic_usage()
show_print_usage()
elif command == "translate":
if len(command_args) >= 1:
if sys.version_info[0] == 2:
c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
cr = colorama.Style.RESET_ALL
msg = "The SeleniumBase Translator does NOT support Python 2!"
message = "\n" + c5 + msg + cr + "\n"
print("")
raise Exception(message)
from seleniumbase.translate import translator

translator.main()
else:
show_basic_usage()
show_translate_usage()
elif command == "extract-objects" or command == "extract_objects":
if len(command_args) >= 1:
from seleniumbase.console_scripts import sb_objectify

sb_objectify.extract_objects()
else:
show_basic_usage()
Expand All @@ -1154,31 +1133,27 @@ def main():
elif command == "objectify":
if len(command_args) >= 1:
from seleniumbase.console_scripts import sb_objectify

sb_objectify.objectify()
else:
show_basic_usage()
show_objectify_usage()
elif command == "revert-objects" or command == "revert_objects":
if len(command_args) >= 1:
from seleniumbase.console_scripts import sb_objectify

sb_objectify.revert_objects()
else:
show_basic_usage()
show_revert_objects_usage()
elif command == "encrypt" or command == "obfuscate":
if len(command_args) >= 0:
from seleniumbase.common import obfuscate

obfuscate.main()
else:
show_basic_usage()
show_encrypt_usage()
elif command == "decrypt" or command == "unobfuscate":
if len(command_args) >= 0:
from seleniumbase.common import unobfuscate

unobfuscate.main()
else:
show_basic_usage()
Expand All @@ -1188,31 +1163,27 @@ def main():
from seleniumbase.utilities.selenium_grid import (
download_selenium_server,
)

download_selenium_server.main(force_download=True)
else:
show_basic_usage()
show_download_usage()
elif command == "grid-hub" or command == "grid_hub":
if len(command_args) >= 1:
from seleniumbase.utilities.selenium_grid import grid_hub

grid_hub.main()
else:
show_basic_usage()
show_grid_hub_usage()
elif command == "grid-node" or command == "grid_node":
if len(command_args) >= 1:
from seleniumbase.utilities.selenium_grid import grid_node

grid_node.main()
else:
show_basic_usage()
show_grid_node_usage()
elif command == "version" or command == "--version" or command == "-v":
if len(command_args) == 0:
from seleniumbase.console_scripts import logo_helper

seleniumbase_logo = logo_helper.get_seleniumbase_logo()
print(seleniumbase_logo)
print("")
Expand All @@ -1231,7 +1202,6 @@ def main():
import fasteners
import os
import warnings

with warnings.catch_warnings():
warnings.simplefilter("ignore", category=UserWarning)
pip_find_lock = fasteners.InterProcessLock(
Expand Down
7 changes: 0 additions & 7 deletions seleniumbase/console_scripts/sb_behave_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
from seleniumbase.fixtures import shared_utils
from tkinter.scrolledtext import ScrolledText

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


def set_colors(use_colors):
c0 = ""
Expand Down
7 changes: 0 additions & 7 deletions seleniumbase/console_scripts/sb_caseplans.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@
from tkinter import messagebox
from tkinter.scrolledtext import ScrolledText

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


def set_colors(use_colors):
c0 = ""
Expand Down
7 changes: 0 additions & 7 deletions seleniumbase/console_scripts/sb_commander.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@
from seleniumbase.fixtures import shared_utils
from tkinter.scrolledtext import ScrolledText

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


def set_colors(use_colors):
c0 = ""
Expand Down
6 changes: 0 additions & 6 deletions seleniumbase/console_scripts/sb_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@
sys_executable = sys.executable
if " " in sys_executable:
sys_executable = "python"
if sys.version_info <= (3, 8):
current_version = ".".join(str(ver) for ver in sys.version_info[:3])
raise Exception(
"\n* Recorder Desktop requires Python 3.8 or newer!"
"\n*** You are currently using Python %s" % current_version
)


def set_colors(use_colors):
Expand Down
Loading
Loading