Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2a26bed

Browse files
authored
Merge pull request #4007 from seleniumbase/cdp-mode-patch-62
CDP Mode: Patch 62
2 parents ca92a51 + c5d1654 commit 2a26bed

File tree

21 files changed

+120
-50
lines changed

21 files changed

+120
-50
lines changed

‎README.md‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ with SB(uc=True, test=True, locale="en") as sb:
103103
sb.assert_text("Username", '[for="user_login"]', timeout=3)
104104
sb.assert_element('label[for="user_login"]')
105105
sb.highlight('button:contains("Sign in")')
106-
sb.highlight('h1:contains("GitLab.com")')
106+
sb.highlight('h1:contains("GitLab")')
107107
sb.post_message("SeleniumBase wasn't detected", duration=4)
108108
```
109109

@@ -118,13 +118,11 @@ url = "https://gitlab.com/users/sign_in"
118118
sb = sb_cdp.Chrome(url)
119119
sb.sleep(2.5)
120120
sb.gui_click_captcha()
121-
sb.highlight('h1:contains("GitLab.com")')
121+
sb.highlight('h1:contains("GitLab")')
122122
sb.highlight('button:contains("Sign in")')
123123
sb.driver.stop()
124124
```
125125

126-
> (Due to changes in Chrome 137 where the `--load-extension` switch was removed, you can't load extensions directly from this format.)
127-
128126
--------
129127

130128
<p align="left">📗 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_get_swag.py">SeleniumBase/examples/test_get_swag.py</a>, which tests an e-commerce site:</p>

‎examples/cdp_mode/ReadMe.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,14 @@ sb.cdp.get_element_attributes(selector)
460460
sb.cdp.get_element_attribute(selector, attribute)
461461
sb.cdp.get_attribute(selector, attribute)
462462
sb.cdp.get_element_html(selector)
463+
sb.cdp.get_mfa_code(totp_key=None)
464+
sb.cdp.enter_mfa_code(selector, totp_key=None, timeout=None)
463465
sb.cdp.set_locale(locale)
464466
sb.cdp.set_local_storage_item(key, value)
465467
sb.cdp.set_session_storage_item(key, value)
466468
sb.cdp.set_attributes(selector, attribute, value)
469+
sb.cdp.is_attribute_present(selector, attribute, value=None)
470+
sb.cdp.is_online()
467471
sb.cdp.gui_press_key(key)
468472
sb.cdp.gui_press_keys(keys)
469473
sb.cdp.gui_write(text)

‎examples/cdp_mode/raw_cdp_gitlab.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
sb = sb_cdp.Chrome(url, incognito=True)
55
sb.sleep(2.2)
66
sb.gui_click_captcha()
7-
sb.highlight('h1:contains("GitLab.com")')
7+
sb.highlight('h1:contains("GitLab")')
88
sb.highlight('button:contains("Sign in")')
99
sb.driver.stop()

‎examples/cdp_mode/raw_gitlab.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
sb.assert_text("Username", '[for="user_login"]', timeout=3)
1010
sb.assert_element('label[for="user_login"]')
1111
sb.highlight('button:contains("Sign in")')
12-
sb.highlight('h1:contains("GitLab.com")')
12+
sb.highlight('h1:contains("GitLab")')
1313
sb.post_message("SeleniumBase wasn't detected", duration=4)

‎examples/cdp_mode/raw_mfa_login.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from seleniumbase import sb_cdp
2+
3+
url = "https://seleniumbase.io/realworld/login"
4+
sb = sb_cdp.Chrome(url)
5+
sb.type("#username", "demo_user")
6+
sb.type("#password", "secret_pass")
7+
sb.enter_mfa_code("#totpcode", "GAXG2MTEOR3DMMDG")
8+
sb.assert_text("Welcome!", "h1")
9+
sb.click('a:contains("This Page")')
10+
sb.highlight("h1")
11+
sb.highlight("img#image1")
12+
sb.driver.stop()

‎examples/cdp_mode/raw_proxy.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def main():
4343
if row.strip() != "":
4444
data.append(row.strip())
4545
print("\n".join(data).replace('\n"', ' "'))
46+
sb.click_if_visible(pop_up)
4647
sb.sleep(3)
4748
sb.driver.stop()
4849

‎examples/presenter/uc_presentation.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def test_presentation(self):
353353
sb.assert_text("Username", '[for="user_login"]', timeout=3)
354354
sb.assert_element('[for="user_login"]')
355355
sb.highlight('button:contains("Sign in")')
356-
sb.highlight('h1:contains("GitLab.com")')
356+
sb.highlight('h1:contains("GitLab")')
357357
sb.post_message("SeleniumBase wasn't detected", duration=4)
358358

359359
self.create_presentation(theme="serif", transition="fade")

‎examples/presenter/uc_presentation_3.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def test_presentation_3(self):
6363
sb.assert_text("Username", '[for="user_login"]', timeout=3)
6464
sb.assert_element('[for="user_login"]')
6565
sb.highlight('button:contains("Sign in")')
66-
sb.highlight('h1:contains("GitLab.com")')
66+
sb.highlight('h1:contains("GitLab")')
6767
sb.post_message("SeleniumBase wasn't detected", duration=4)
6868

6969
self.create_presentation(theme="serif", transition="none")
@@ -91,7 +91,7 @@ def test_presentation_3(self):
9191
'<mk-2> sb.assert_element(\'[for="user_login"]\')</mk-2>\n'
9292
'<mk-3> sb.highlight(\'button:contains("Sign in")\')'
9393
'</mk-3>\n'
94-
'<mk-4> sb.highlight(\'h1:contains("GitLab.com")\')'
94+
'<mk-4> sb.highlight(\'h1:contains("GitLab")\')'
9595
'</mk-4>\n'
9696
'<mk-5> sb.post_message("SeleniumBase wasn\'t detected",'
9797
' duration=4)</mk-5>\n'

‎examples/presenter/uc_presentation_4.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def test_presentation_4(self):
390390
sb.assert_text("Username", '[for="user_login"]', timeout=3)
391391
sb.assert_element('label[for="user_login"]')
392392
sb.highlight('button:contains("Sign in")')
393-
sb.highlight('h1:contains("GitLab.com")')
393+
sb.highlight('h1:contains("GitLab")')
394394
sb.post_message("SeleniumBase wasn't detected", duration=8)
395395

396396
self.create_presentation(theme="serif", transition="none")
@@ -528,6 +528,12 @@ def test_presentation_4(self):
528528
required_text = "Catan"
529529
sb.cdp.press_keys('input[aria-label="Search"]', search + "\n")
530530
sb.sleep(3.8)
531+
if sb.is_element_visible("#px-captcha"):
532+
sb.cdp.gui_click_and_hold("#px-captcha", 12)
533+
sb.sleep(3.2)
534+
if sb.is_element_visible("#px-captcha"):
535+
sb.cdp.gui_click_and_hold("#px-captcha", 12)
536+
sb.sleep(3.2)
531537
sb.cdp.remove_elements('[data-testid="skyline-ad"]')
532538
print('*** Walmart Search for "%s":' % search)
533539
print(' (Results must contain "%s".)' % required_text)

‎examples/proxy_test.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ def test_proxy(self):
4545
if row.strip() != "":
4646
data.append(row.strip())
4747
print("\n".join(data).replace('\n"', ' "'))
48+
self.click_if_visible(pop_up)
4849
self.sleep(3)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /