Skip to content

Commit 152d689

Browse files
ENH: Trying to ensure there is an active page before running the CDP command
1 parent 4bd95a9 commit 152d689

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

botcity/web/bot.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,11 @@ def _others_configurations(self):
356356
https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/260#issuecomment-901276808.
357357
It will be a temporary solution.
358358
"""
359+
try:
360+
self.driver.get("about:blank")
361+
except Exception:
362+
pass
363+
359364
params = {
360365
"behavior": "allow",
361366
"downloadPath": self.download_folder_path

conftest.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,8 @@ def setup_undetected_chrome(headless: bool, tmp_folder: str, download_driver: st
4545
web = WebBot(headless)
4646
web.browser = Browser.UNDETECTED_CHROME
4747

48-
opt = browsers.undetected_chrome.default_options(headless=headless, download_folder_path=tmp_folder)
49-
opt.add_argument("--disable-dev-shm-usage")
50-
opt.add_argument("--disable-extensions")
51-
5248
web.driver_path = download_driver
5349
web.download_folder_path = tmp_folder
54-
web.options = opt
5550
return web
5651

5752

tests/test_browser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def test_create_window(web: WebBot):
4343
def test_display_size(web: WebBot):
4444
web.browse(conftest.INDEX_PAGE)
4545
web.set_screen_resolution(1280, 720)
46+
web.wait(3000)
4647
(w, h) = web.display_size()
4748

4849
assert w in [1280, 1233, 1223, 1028, 1264, 1176, 1256]
@@ -242,6 +243,7 @@ def test_scroll_up(web: WebBot):
242243
def test_set_screen_resolution(web: WebBot):
243244
web.browse(conftest.INDEX_PAGE)
244245
web.set_screen_resolution(500, 500)
246+
web.wait(3000)
245247

246248
page_size = web.find_element('page-size', By.ID).text
247249
width = page_size.split('x')[0]

tests/test_vision.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def test_get_last_element(web: WebBot):
4848
def test_find_text(web: WebBot):
4949
web.browse(conftest.INDEX_PAGE)
5050
web.set_screen_resolution(3000, 2000)
51+
web.wait(3000)
5152

5253
web.add_image('hello_world', os.path.join(conftest.PROJECT_DIR, 'resources', 'hello_world.png'))
5354
ele = web.find("hello_world", matching=0.97, waiting_time=20000)

0 commit comments

Comments
 (0)