Skip to content

Commit a8c0181

Browse files
committed
Do some refactoring
1 parent 1c503bd commit a8c0181

3 files changed

Lines changed: 2 additions & 76 deletions

File tree

seleniumbase/core/mysql.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ class DatabaseManager:
77
def __init__(self, database_env="test", conf_creds=None):
88
"""Create a connection to the MySQL DB."""
99
import fasteners
10-
import sys
1110
import time
1211
from seleniumbase import config as sb_config
1312
from seleniumbase.config import settings
@@ -19,18 +18,6 @@ def __init__(self, database_env="test", conf_creds=None):
1918
constants.PipInstall.FINDLOCK
2019
)
2120
with pip_find_lock:
22-
if sys.version_info < (3, 9):
23-
# Fix bug with newer cryptography on Python 3.8:
24-
# "pyo3_runtime.PanicException: Python API call failed"
25-
# (Match the version needed for pdfminer.six functions)
26-
try:
27-
import cryptography
28-
if cryptography.__version__ != "39.0.2":
29-
shared_utils.pip_install(
30-
"cryptography", version="39.0.2"
31-
)
32-
except Exception:
33-
shared_utils.pip_install("cryptography", version="39.0.2")
3421
try:
3522
import cryptography # noqa: F401
3623
import pymysql

seleniumbase/fixtures/base_case.py

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14732,36 +14732,10 @@ def __get_shadow_element(
1473214732
is_present = False
1473314733
for selector_part in selectors[1:]:
1473414734
shadow_root = None
14735-
if (
14736-
(self.is_chromium() or self.browser == "firefox")
14737-
and int(self.__get_major_browser_version()) >= 96
14738-
):
14735+
if self.is_chromium() or self.browser == "firefox":
1473914736
try:
1474014737
shadow_root = element.shadow_root
1474114738
except Exception:
14742-
if self.is_chromium():
14743-
chrome_dict = self.driver.capabilities["chrome"]
14744-
chrome_dr_version = chrome_dict["chromedriverVersion"]
14745-
chromedriver_version = chrome_dr_version.split(" ")[0]
14746-
major_c_dr_version = chromedriver_version.split(".")[0]
14747-
if int(major_c_dr_version) < 96:
14748-
upgrade_to = "latest"
14749-
major_browser_version = (
14750-
self.__get_major_browser_version()
14751-
)
14752-
if int(major_browser_version) >= 96:
14753-
upgrade_to = str(major_browser_version)
14754-
message = (
14755-
"You need to upgrade to a newer\n"
14756-
"version of chromedriver to interact\n"
14757-
"with Shadow root elements!\n"
14758-
"(Current driver version is: %s)"
14759-
"\n(Minimum driver version is: 96.*)"
14760-
"\nTo upgrade, run this:"
14761-
'\n"seleniumbase get chromedriver %s"'
14762-
% (chromedriver_version, upgrade_to)
14763-
)
14764-
raise Exception(message)
1476514739
if timeout != 0.1: # Skip wait for special 0.1 (See above)
1476614740
time.sleep(2)
1476714741
try:
@@ -14770,12 +14744,7 @@ def __get_shadow_element(
1477014744
raise Exception(
1477114745
"Element {%s} has no shadow root!" % selector_chain
1477214746
)
14773-
else: # This part won't work on Chrome 96 or newer.
14774-
# If using Chrome 96 or newer (and on an old Python version),
14775-
# you'll need to upgrade in order to access Shadow roots.
14776-
# Firefox users will likely hit:
14777-
# https://github.com/mozilla/geckodriver/issues/1711
14778-
# When Firefox adds support, switch to element.shadow_root
14747+
else:
1477914748
try:
1478014749
shadow_root = self.execute_script(
1478114750
"return arguments[0].shadowRoot;", element

seleniumbase/undetected/cdp_driver/connection.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -133,31 +133,6 @@ def __repr__(self):
133133
return fmt
134134

135135

136-
class EventTransaction(Transaction):
137-
event = None
138-
value = None
139-
140-
def __init__(self, event_object):
141-
try:
142-
super().__init__(None)
143-
except BaseException:
144-
pass
145-
self.set_result(event_object)
146-
self.event = self.value = self.result()
147-
148-
def __repr__(self):
149-
status = "finished"
150-
success = False if self.exception() else True
151-
event_object = self.result()
152-
fmt = (
153-
f"{self.__class__.__name__}\n\t"
154-
f"event: {event_object.__class__.__module__}.{event_object.__class__.__name__}\n\t" # noqa
155-
f"status: {status}\n\t"
156-
f"success: {success}>"
157-
)
158-
return fmt
159-
160-
161136
class CantTouchThis(type):
162137
def __setattr__(cls, attr, value):
163138
""":meta private:"""
@@ -619,11 +594,6 @@ async def listener_loop(self):
619594
# Probably an event
620595
try:
621596
event = cdp.util.parse_json_event(message)
622-
# event_tx = EventTransaction(event)
623-
# if not self.connection.mapper:
624-
# self.connection.__count__ = itertools.count(0)
625-
# event_tx.id = next(self.connection.__count__)
626-
# self.connection.mapper[event_tx.id] = event_tx
627597
except Exception as e:
628598
logger.info(
629599
"%s: %s during parsing of json from event : %s"

0 commit comments

Comments
 (0)