Skip to content

Various updates #3006

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

Merged
merged 7 commits into from
Aug 7, 2024
Merged
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
10 changes: 0 additions & 10 deletions help_docs/uc_mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,6 @@ The above JS method is used within the <b><code translate="no">SeleniumBase</cod

--------

🛠️ <b>Troubleshooting UC Mode</b>

On Windows, the `uc_gui_click_captcha()` method requires "Scaling" to be set at "100%". (Note that "100%" may be different from the system's "Recommended" percent, which can be higher depending on your screen resolution and monitor size.)

<img src="https://seleniumbase.github.io/other/ts_uc_1.jpg" title="Make sure Scaling is set to 100%" width="410">

As an alternative to using the `uc_gui_click_captcha()` method on Windows, you can use `sb.uc_gui_handle_captcha()`, which does not require "Scaling" to be set to a specific value. Instead of using the mouse to click a CAPTCHA, `sb.uc_gui_handle_captcha()` uses a combination of the `TAB` key and the `SPACEBAR`.

--------

🏆 <b>Choosing the right CAPTCHA service</b> for your business / website:

<img src="https://seleniumbase.github.io/other/me_se_conf.jpg" title="SeleniumBase" width="370">
Expand Down
15 changes: 8 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ setuptools>=68.0.0;python_version<"3.8"
setuptools~=70.2;python_version>="3.8" and python_version<"3.10"
setuptools>=70.2.0;python_version>="3.10"
wheel>=0.42.0;python_version<"3.8"
wheel>=0.43.0;python_version>="3.8"
attrs>=23.2.0
wheel>=0.44.0;python_version>="3.8"
attrs>=24.2.0
certifi>=2024.7.4
exceptiongroup>=1.2.2
filelock>=3.12.2;python_version<"3.8"
Expand All @@ -17,7 +17,8 @@ platformdirs>=4.2.2;python_version>="3.8"
typing-extensions>=4.12.2;python_version>="3.8"
parse>=1.20.2
parse-type>=0.6.2
pyyaml>=6.0.1
pyyaml==6.0.1;python_version<"3.8"
pyyaml>=6.0.2;python_version>="3.8"
six==1.16.0
idna==3.7
chardet==5.2.0
Expand All @@ -30,7 +31,7 @@ sniffio==1.3.1
h11==0.14.0
outcome==1.3.0.post0
trio==0.22.2;python_version<"3.8"
trio==0.26.0;python_version>="3.8"
trio==0.26.1;python_version>="3.8"
trio-websocket==0.11.1
wsproto==1.2.0
websocket-client==1.8.0;python_version>="3.8"
Expand Down Expand Up @@ -78,13 +79,13 @@ rich==13.7.1
# ("pip install -r requirements.txt" also installs this, but "pip install -e ." won't.)

coverage==7.2.7;python_version<"3.8"
coverage>=7.6.0;python_version>="3.8"
coverage>=7.6.1;python_version>="3.8"
pytest-cov==4.1.0;python_version<"3.8"
pytest-cov>=5.0.0;python_version>="3.8"
flake8==5.0.4;python_version<"3.9"
flake8==7.1.0;python_version>="3.9"
flake8==7.1.1;python_version>="3.9"
mccabe==0.7.0
pyflakes==2.5.0;python_version<"3.9"
pyflakes==3.2.0;python_version>="3.9"
pycodestyle==2.9.1;python_version<"3.9"
pycodestyle==2.12.0;python_version>="3.9"
pycodestyle==2.12.1;python_version>="3.9"
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.29.6"
__version__ = "4.29.7"
2 changes: 1 addition & 1 deletion seleniumbase/console_scripts/sb_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
DRIVER_DIR = os.path.dirname(os.path.realpath(drivers.__file__))
LOCAL_PATH = "/usr/local/bin/" # On Mac and Linux systems
DEFAULT_CHROMEDRIVER_VERSION = "114.0.5735.90" # (If can't find LATEST_STABLE)
DEFAULT_GECKODRIVER_VERSION = "v0.34.0"
DEFAULT_GECKODRIVER_VERSION = "v0.35.0"
DEFAULT_EDGEDRIVER_VERSION = "115.0.1901.183" # (If can't find LATEST_STABLE)


Expand Down
37 changes: 35 additions & 2 deletions seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ def _uc_gui_click_captcha(
)
with gui_lock: # Prevent issues with multiple processes
needs_switch = False
width_ratio = 1.0
is_in_frame = js_utils.is_in_frame(driver)
if is_in_frame and driver.is_element_present("#challenge-stage"):
driver.switch_to.parent_frame()
Expand All @@ -791,6 +792,20 @@ def _uc_gui_click_captcha(
page_actions.switch_to_window(
driver, driver.current_window_handle, 2, uc_lock=False
)
if IS_WINDOWS:
window_rect = driver.get_window_rect()
width = window_rect["width"]
height = window_rect["height"]
win_x = window_rect["x"]
win_y = window_rect["y"]
scr_width = pyautogui.size().width
driver.maximize_window()
win_width = driver.get_window_size()["width"]
width_ratio = round(float(scr_width) / float(win_width), 2) + 0.01
if width_ratio < 0.45 or width_ratio > 2.55:
width_ratio = 1.01
driver.minimize_window()
driver.set_window_rect(win_x, win_y, width, height)
if ctype == "cf_t":
if (
driver.is_element_present(".cf-turnstile-wrapper iframe")
Expand Down Expand Up @@ -1015,6 +1030,18 @@ def _uc_gui_handle_captcha(
page_actions.switch_to_window(
driver, driver.current_window_handle, 2, uc_lock=False
)
if IS_WINDOWS and hasattr(pyautogui, "getActiveWindowTitle"):
py_a_g_title = pyautogui.getActiveWindowTitle()
window_title = driver.title
if not py_a_g_title.startswith(window_title):
window_rect = driver.get_window_rect()
width = window_rect["width"]
height = window_rect["height"]
win_x = window_rect["x"]
win_y = window_rect["y"]
driver.minimize_window()
driver.set_window_rect(win_x, win_y, width, height)
time.sleep(0.33)
if ctype == "cf_t":
if (
driver.is_element_present(".cf-turnstile-wrapper iframe")
Expand Down Expand Up @@ -1688,7 +1715,10 @@ def _set_chrome_options(
chrome_options.add_argument("--ignore-certificate-errors")
if not enable_ws:
chrome_options.add_argument("--disable-web-security")
if IS_LINUX or not is_using_uc(undetectable, browser_name):
if (
IS_LINUX
or (IS_MAC and not is_using_uc(undetectable, browser_name))
):
chrome_options.add_argument("--no-sandbox")
if remote_debug:
# To access the Debugger, go to: chrome://inspect/#devices
Expand Down Expand Up @@ -3405,7 +3435,10 @@ def get_local_driver(
edge_options.add_argument("--allow-running-insecure-content")
if user_agent:
edge_options.add_argument("--user-agent=%s" % user_agent)
if IS_LINUX or not is_using_uc(undetectable, browser_name):
if (
IS_LINUX
or (IS_MAC and not is_using_uc(undetectable, browser_name))
):
edge_options.add_argument("--no-sandbox")
if remote_debug:
# To access the Debugger, go to: edge://inspect/#devices
Expand Down
7 changes: 7 additions & 0 deletions seleniumbase/fixtures/page_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ def recalculate_selector(selector, by, xp_ok=True):
by = By.XPATH
if by == "":
by = By.CSS_SELECTOR
if not is_valid_by(by):
valid_by_options = [
"css selector", "link text", "partial link text",
"name", "xpath", "id", "tag name", "class name",
]
msg = "Choose a `by` from: %s." % valid_by_options
raise Exception('Invalid `by`: "%s"\n%s' % (by, msg))
return (selector, by)


Expand Down
17 changes: 9 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@
'setuptools~=70.2;python_version>="3.8" and python_version<"3.10"',
'setuptools>=70.2.0;python_version>="3.10"', # 71.0.x has issues
'wheel>=0.42.0;python_version<"3.8"',
'wheel>=0.43.0;python_version>="3.8"',
'attrs>=23.2.0',
'wheel>=0.44.0;python_version>="3.8"',
'attrs>=24.2.0',
"certifi>=2024.7.4",
"exceptiongroup>=1.2.2",
'filelock>=3.12.2;python_version<"3.8"',
Expand All @@ -165,7 +165,8 @@
'typing-extensions>=4.12.2;python_version>="3.8"',
'parse>=1.20.2',
'parse-type>=0.6.2',
'pyyaml>=6.0.1',
'pyyaml==6.0.1;python_version<"3.8"',
'pyyaml>=6.0.2;python_version>="3.8"',
"six==1.16.0",
"idna==3.7",
'chardet==5.2.0',
Expand All @@ -178,7 +179,7 @@
'h11==0.14.0',
'outcome==1.3.0.post0',
'trio==0.22.2;python_version<"3.8"',
'trio==0.26.0;python_version>="3.8"',
'trio==0.26.1;python_version>="3.8"',
'trio-websocket==0.11.1',
'wsproto==1.2.0',
'websocket-client==1.8.0;python_version>="3.8"',
Expand Down Expand Up @@ -235,20 +236,20 @@
# Usage: coverage run -m pytest; coverage html; coverage report
"coverage": [
'coverage==7.2.7;python_version<"3.8"',
'coverage>=7.6.0;python_version>="3.8"',
'coverage>=7.6.1;python_version>="3.8"',
'pytest-cov==4.1.0;python_version<"3.8"',
'pytest-cov>=5.0.0;python_version>="3.8"',
],
# pip install -e .[flake8]
# Usage: flake8
"flake8": [
'flake8==5.0.4;python_version<"3.9"',
'flake8==7.1.0;python_version>="3.9"',
'flake8==7.1.1;python_version>="3.9"',
"mccabe==0.7.0",
'pyflakes==2.5.0;python_version<"3.9"',
'pyflakes==3.2.0;python_version>="3.9"',
'pycodestyle==2.9.1;python_version<"3.9"',
'pycodestyle==2.12.0;python_version>="3.9"',
'pycodestyle==2.12.1;python_version>="3.9"',
],
# pip install -e .[ipdb]
# (Not needed for debugging anymore. SeleniumBase now includes "pdbp".)
Expand All @@ -264,7 +265,7 @@
'cryptography==39.0.2;python_version<"3.9"',
'cryptography==43.0.0;python_version>="3.9"',
'cffi==1.15.1;python_version<"3.8"',
'cffi==1.16.0;python_version>="3.8"',
'cffi==1.17.0;python_version>="3.8"',
"pycparser==2.22",
],
# pip install -e .[pillow]
Expand Down