Skip to content

Commit 4310a4d

Browse files
authored
Merge pull request #3159 from seleniumbase/multiple-updates
Multiple updates (options, etc.)
2 parents 6b6db12 + 3e2938f commit 4310a4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1318
-1081
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ pytest test_coffee_cart.py --trace
657657
--headless2 # (Use the new headless mode, which supports extensions.)
658658
--headed # (Run tests in headed/GUI mode on Linux OS, where not default.)
659659
--xvfb # (Run tests using the Xvfb virtual display server on Linux OS.)
660+
--xvfb-metrics=STRING # (Set Xvfb display size on Linux: "Width,Height".)
660661
--locale=LOCALE_CODE # (Set the Language Locale Code for the web browser.)
661662
--interval=SECONDS # (The autoplay interval for presentations & tour steps)
662663
--start-page=URL # (The starting URL for the web browser when tests begin.)
@@ -701,6 +702,7 @@ pytest test_coffee_cart.py --trace
701702
--rcs | --reuse-class-session # (Reuse session for tests in class.)
702703
--crumbs # (Delete all cookies between tests reusing a session.)
703704
--disable-beforeunload # (Disable the "beforeunload" event on Chrome.)
705+
--window-position=X,Y # (Set the browser's starting window position.)
704706
--window-size=WIDTH,HEIGHT # (Set the browser's starting window size.)
705707
--maximize # (Start tests with the browser window maximized.)
706708
--screenshot # (Save a screenshot at the end of each test.)
@@ -869,7 +871,7 @@ pytest test_suite.py --dashboard --html=report.html
869871
870872
<img src="https://seleniumbase.github.io/cdn/img/dash_report.jpg" alt="Dashboard Pytest HTML Report" title="Dashboard Pytest HTML Report" width="520" />
871873
872-
If viewing pytest html reports in [Jenkins](https://www.jenkins.io/), you may need to [configure Jenkins settings](https://stackoverflow.com/a/46197356) for the html to render correctly. This is due to [Jenkins CSP changes](https://www.jenkins.io/doc/book/system-administration/security/configuring-content-security-policy/).
874+
If viewing pytest html reports in [Jenkins](https://www.jenkins.io/), you may need to [configure Jenkins settings](https://stackoverflow.com/a/46197356/7058266) for the html to render correctly. This is due to [Jenkins CSP changes](https://www.jenkins.io/doc/book/system-administration/security/configuring-content-security-policy/).
873875
874876
You can also use ``--junit-xml=report.xml`` to get an xml report instead. Jenkins can use this file to display better reporting for your tests.
875877

examples/custom_settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464
# If True and --proxy=IP_ADDRESS:PORT is invalid, then error immediately.
6565
RAISE_INVALID_PROXY_STRING_EXCEPTION = True
6666

67+
# Default browser coordinates when opening new windows for tests.
68+
WINDOW_START_X = 20
69+
WINDOW_START_Y = 54
70+
6771
# Default browser resolutions when opening new windows for tests.
6872
# (Headless resolutions take priority, and include all browsers.)
6973
# (Firefox starts maximized by default when running in GUI Mode.)

examples/dialog_boxes/dialog_box_tour.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ def test_dialog_boxes(self):
108108
self.highlight_type('input[aria-label="Search"]', text + "\n")
109109
else:
110110
self.open("https://en.wikipedia.org/wiki/Special:Search")
111-
self.highlight_type('input[id*="search"]', text + "\n")
111+
self.highlight_type('input[id*="search"]', text)
112+
self.sleep(1)
113+
self.click("#searchform button")
112114
self.wait_for_ready_state_complete()
113115
self.sleep(1)
114116
self.highlight("body")

examples/example_logs/ReadMe.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ pytest test_suite.py --dashboard --html=report.html
7474

7575
--------
7676

77-
If viewing ``pytest-html`` reports in [Jenkins](https://www.jenkins.io/), you may need to [configure Jenkins settings](https://stackoverflow.com/a/46197356) for the HTML to render correctly. This is due to [Jenkins CSP changes](https://www.jenkins.io/doc/book/security/configuring-content-security-policy/). That setting can be changed from ``Manage Jenkins`` > ``Script Console`` by running:
77+
If viewing ``pytest-html`` reports in [Jenkins](https://www.jenkins.io/), you may need to [configure Jenkins settings](https://stackoverflow.com/a/46197356/7058266) for the HTML to render correctly. This is due to [Jenkins CSP changes](https://www.jenkins.io/doc/book/security/configuring-content-security-policy/). That setting can be changed from ``Manage Jenkins`` > ``Script Console`` by running:
7878

79-
```
79+
```js
8080
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")
8181
```
8282

examples/presenter/uc_presentation.py

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import subprocess
3+
from contextlib import suppress
34
from seleniumbase import BaseCase
45
from seleniumbase import SB
56
BaseCase.main(__name__, __file__)
@@ -8,6 +9,7 @@
89
class UCPresentationClass(BaseCase):
910
def test_presentation(self):
1011
self.open("data:,")
12+
self._output_file_saves = False
1113
self.create_presentation(theme="beige", transition="fade")
1214
self.add_slide(
1315
"<p>A deep dive into <b>undetectable automation</b>, with:</p>"
@@ -235,7 +237,8 @@ def test_presentation(self):
235237
"<mk-2>from seleniumbase import Driver</mk-2>\n\n"
236238
"<mk-3>driver = Driver(uc=True)</mk-3>\n"
237239
"<mk-4>try:</mk-4>\n"
238-
' <mk-5>driver.get("https://nowsecure.nl/#relax")</mk-5>\n'
240+
' <mk-5>driver.get("https://gitlab.com/users/sign_in")'
241+
'</mk-5>\n'
239242
" <mk-1><mk-6>driver.sleep(4)</mk-6></mk-1>\n"
240243
" <mk-7># DO MORE STUFF</mk-7>\n"
241244
"<mk-4>finally:</mk-4>\n"
@@ -263,7 +266,7 @@ def test_presentation(self):
263266
)
264267
self.begin_presentation(filename="uc_presentation.html")
265268

266-
try:
269+
with suppress(Exception):
267270
with SB(uc=True) as sb:
268271
sb.get("https://seleniumbase.io/simple/login")
269272
sb.type("#username", "demo_user")
@@ -274,8 +277,6 @@ def test_presentation(self):
274277
sb.highlight("#image1")
275278
sb.click_link("Sign out")
276279
sb.assert_text("signed out", "#top_message")
277-
except Exception:
278-
pass
279280

280281
self.create_presentation(theme="serif", transition="fade")
281282
self.add_slide(
@@ -298,7 +299,7 @@ def test_presentation(self):
298299
)
299300
self.begin_presentation(filename="uc_presentation.html")
300301

301-
try:
302+
with suppress(Exception):
302303
with SB(uc=True, demo=True) as sb:
303304
sb.get("https://seleniumbase.io/simple/login")
304305
sb.type("#username", "demo_user")
@@ -309,8 +310,6 @@ def test_presentation(self):
309310
sb.highlight("#image1")
310311
sb.click_link("Sign out")
311312
sb.assert_text("signed out", "#top_message")
312-
except Exception:
313-
pass
314313

315314
self.create_presentation(theme="serif", transition="fade")
316315
self.add_slide(
@@ -339,29 +338,22 @@ def test_presentation(self):
339338
code=(
340339
"from seleniumbase import SB\n\n"
341340
"with SB(uc=True) as sb:\n"
342-
' sb.get("https://nowsecure.nl/#relax")\n'
343-
" sb.sleep(1)\n"
344-
' if not sb.is_text_visible("OH YEAH, you passed", "h1"):\n'
345-
" sb.get_new_driver(undetectable=True)\n"
346-
' sb.get("https://nowsecure.nl/#relax")\n'
347-
" sb.sleep(1)\n"
348-
' sb.activate_demo_mode()\n'
349-
' sb.assert_text("OH YEAH, you passed!", "h1", timeout=3)\n'
341+
' url = "https://gitlab.com/users/sign_in"\n'
342+
" sb.uc_open_with_reconnect(url, 4)\n\n"
343+
" ...\n"
350344
),
351345
)
352346
self.begin_presentation(filename="uc_presentation.html")
353347

354-
try:
348+
with suppress(Exception):
355349
with SB(uc=True) as sb:
356-
sb.uc_open_with_tab("https://nowsecure.nl/#relax")
357-
sb.sleep(1)
358-
if not sb.is_text_visible("OH YEAH, you passed", "h1"):
359-
sb.uc_open_with_tab("https://nowsecure.nl/#relax")
360-
sb.sleep(1)
361-
sb.activate_demo_mode()
362-
sb.assert_text("OH YEAH, you passed!", "h1", timeout=3)
363-
except Exception:
364-
pass
350+
url = "https://gitlab.com/users/sign_in"
351+
sb.uc_open_with_reconnect(url, 4)
352+
sb.assert_text("Username", '[for="user_login"]', timeout=3)
353+
sb.assert_element('[for="user_login"]')
354+
sb.highlight('button:contains("Sign in")')
355+
sb.highlight('h1:contains("GitLab.com")')
356+
sb.post_message("SeleniumBase wasn't detected", duration=4)
365357

366358
self.create_presentation(theme="serif", transition="fade")
367359
self.add_slide(
@@ -495,11 +487,12 @@ def test_presentation(self):
495487
code=(
496488
"# Example:\n"
497489
"<mk-1>driver.uc_open_with_reconnect(\n"
498-
' "https://nowsecure.nl/#relax", reconnect_time=6\n)</mk-1>'
490+
' "https://steamdb.info/login/", reconnect_time=6\n)'
491+
"</mk-1>"
499492
"\n\n"
500493
"# Short form example:\n"
501494
"<mk-2>driver.uc_open_with_reconnect("
502-
'"https://nowsecure.nl/#relax", 6)</mk-2>\n'
495+
'"https://steamdb.info/login/", 6)</mk-2>\n'
503496
),
504497
)
505498
self.add_slide(

examples/presenter/uc_presentation_3.py

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
from contextlib import suppress
23
from seleniumbase import BaseCase
34
from seleniumbase import SB
45
BaseCase.main(__name__, __file__)
@@ -54,7 +55,7 @@ def test_presentation_3(self):
5455
)
5556
self.begin_presentation(filename="uc_presentation.html")
5657

57-
try:
58+
with suppress(Exception):
5859
with SB(uc=True) as sb:
5960
url = "https://gitlab.com/users/sign_in"
6061
sb.uc_open_with_reconnect(url, 4)
@@ -63,8 +64,6 @@ def test_presentation_3(self):
6364
sb.highlight('button:contains("Sign in")')
6465
sb.highlight('h1:contains("GitLab.com")')
6566
sb.post_message("SeleniumBase wasn't detected", duration=4)
66-
except Exception:
67-
pass
6867

6968
self.create_presentation(theme="serif", transition="none")
7069
self.add_slide(
@@ -151,16 +150,14 @@ def test_presentation_3(self):
151150
if "linux" in sys.platform or "win32" in sys.platform:
152151
agent = None # Use the default UserAgent
153152

154-
try:
153+
with suppress(Exception):
155154
with SB(uc=True, test=True, agent=agent) as sb:
156155
url = "https://gitlab.com/users/sign_in"
157156
sb.uc_open_with_reconnect(url, 4)
158157
sb.uc_gui_handle_captcha() # Only if needed
159158
sb.assert_element('label[for="user_login"]')
160159
sb.set_messenger_theme(location="bottom_center")
161160
sb.post_message("SeleniumBase wasn't detected!")
162-
except Exception:
163-
pass
164161

165162
self.create_presentation(theme="serif", transition="none")
166163
self.add_slide(
@@ -201,16 +198,14 @@ def test_presentation_3(self):
201198
)
202199
self.begin_presentation(filename="uc_presentation.html")
203200

204-
try:
201+
with suppress(Exception):
205202
with SB(uc=True, test=True, agent=agent) as sb:
206203
url = "https://gitlab.com/users/sign_in"
207204
sb.uc_open_with_reconnect(url, 4)
208205
sb.uc_gui_click_captcha() # Only if needed
209206
sb.assert_element('label[for="user_login"]')
210207
sb.set_messenger_theme(location="bottom_center")
211208
sb.post_message("SeleniumBase wasn't detected!")
212-
except Exception:
213-
pass
214209

215210
self.create_presentation(theme="serif", transition="none")
216211
self.add_slide(
@@ -276,7 +271,7 @@ def test_presentation_3(self):
276271
)
277272
self.begin_presentation(filename="uc_presentation.html")
278273

279-
try:
274+
with suppress(Exception):
280275
with SB(uc=True, incognito=True, locale_code="en") as sb:
281276
url = "https://ahrefs.com/website-authority-checker"
282277
input_field = 'input[placeholder="Enter domain"]'
@@ -291,8 +286,6 @@ def test_presentation_3(self):
291286
sb.highlight('a:contains("Top 100 backlinks")')
292287
sb.set_messenger_theme(location="bottom_center")
293288
sb.post_message("SeleniumBase wasn't detected!")
294-
except Exception:
295-
pass
296289

297290
self.create_presentation(theme="serif", transition="none")
298291
self.add_slide(
@@ -312,7 +305,7 @@ def test_presentation_3(self):
312305
)
313306
self.begin_presentation(filename="uc_presentation.html")
314307

315-
try:
308+
with suppress(Exception):
316309
with SB(uc=True, test=True, disable_csp=True) as sb:
317310
url = "https://steamdb.info/"
318311
sb.uc_open_with_reconnect(url, 3)
@@ -324,8 +317,6 @@ def test_presentation_3(self):
324317
sb.highlight('button:contains("Sign in")', scroll=False)
325318
sb.set_messenger_theme(location="top_center")
326319
sb.post_message("SeleniumBase wasn't detected", duration=4)
327-
except Exception:
328-
pass
329320

330321
self.create_presentation(theme="serif", transition="none")
331322
self.add_slide(
@@ -405,16 +396,14 @@ def test_presentation_3(self):
405396
)
406397
self.begin_presentation(filename="uc_presentation.html")
407398

408-
try:
399+
with suppress(Exception):
409400
with SB(uc=True, test=True) as sb:
410401
url = "https://seleniumbase.io/apps/recaptcha"
411402
sb.uc_open_with_reconnect(url)
412403
sb.uc_gui_click_captcha() # Try with PyAutoGUI Click
413404
sb.assert_element("img#captcha-success", timeout=3)
414405
sb.set_messenger_theme(location="top_left")
415406
sb.post_message("SeleniumBase wasn't detected")
416-
except Exception:
417-
pass
418407

419408
self.create_presentation(theme="serif", transition="none")
420409
self.add_slide(
@@ -673,7 +662,7 @@ def test_presentation_3(self):
673662
)
674663
self.begin_presentation(filename="uc_presentation.html")
675664

676-
try:
665+
with suppress(Exception):
677666
with SB(test=True) as sb:
678667
url = "https://seleniumbase.io/hobbit/login"
679668
sb.open(url)
@@ -682,8 +671,6 @@ def test_presentation_3(self):
682671
sb.click("img")
683672
sb.highlight("h1")
684673
sb.sleep(3) # Gandalf: "You Shall Not Pass!"
685-
except Exception:
686-
pass
687674

688675
self.create_presentation(theme="serif", transition="none")
689676
self.add_slide(
@@ -692,7 +679,7 @@ def test_presentation_3(self):
692679
)
693680
self.begin_presentation(filename="uc_presentation.html")
694681

695-
try:
682+
with suppress(Exception):
696683
with SB(uc=True, test=True) as sb:
697684
url = "https://seleniumbase.io/hobbit/login"
698685
sb.uc_open_with_disconnect(url, 2.2)
@@ -703,8 +690,6 @@ def test_presentation_3(self):
703690
sb.post_message("SeleniumBase wasn't detected!")
704691
sb.click("img")
705692
sb.sleep(5.888) # Cool animation happening now!
706-
except Exception:
707-
pass
708693

709694
self.create_presentation(theme="serif", transition="none")
710695
self.add_slide(

examples/test_hack_search.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ def test_hack_search(self):
2525
self.highlight_click('[href*="github.com/seleniumbase/SeleniumBase"]')
2626
self.highlight_click('[href="/seleniumbase/SeleniumBase"]')
2727
self.assert_text("SeleniumBase", "strong a")
28+
self.highlight("strong a")
2829
self.js_click('a[title="examples"]')
29-
self.highlight('td[class*="large"] a[title="test_hack_search.py"]')
30-
self.click('td[class*="large"] a[title="test_hack_search.py"]')
30+
self.highlight('#repo-content-turbo-frame')
31+
self.js_click('a[title="test_hack_search.py"]')
3132
self.assert_text("test_hack_search.py", "#file-name-id-wide")
3233
self.highlight("#file-name-id-wide")

examples/test_parse_soup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ def click_menu_item(self, text):
1414
self.click("#%s" % the_id)
1515

1616
def test_beautiful_soup_parsing(self):
17+
if self.headless:
18+
self.open_if_not_url("about:blank")
19+
self.skip("Skip this test in headless mode!")
1720
self.open("https://seleniumbase.io/tinymce/")
1821
self.wait_for_element("div.mce-container-body")
1922
self.click_menu_item("File")

examples/test_shadow_dom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_shadow_dom(self):
5555
)
5656
remove_button = (
5757
"downloads-manager::shadow #downloadsList"
58-
" downloads-item::shadow #remove-old"
58+
" downloads-item::shadow #quick-remove"
5959
)
6060
no_downloads_area = "downloads-manager::shadow #no-downloads"
6161

examples/test_tinymce.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
class TinyMceTests(BaseCase):
66
def test_tinymce(self):
7+
if self.headless:
8+
self.open_if_not_url("about:blank")
9+
self.skip("Skip this test in headless mode!")
710
self.open("https://seleniumbase.io/tinymce/")
811
self.wait_for_element("div.mce-container-body")
912
self.click('span:contains("File")')

0 commit comments

Comments
 (0)