Skip to content

Commit 2a453c4

Browse files
authored
Merge pull request #1815 from seleniumbase/fix-a-few-bugs
Fix bugs with --archive-logs and headless Firefox on Linux without Xvfb
2 parents a54f571 + 3970874 commit 2a453c4

File tree

7 files changed

+59
-23
lines changed

7 files changed

+59
-23
lines changed

mkdocs_build/requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ click==8.1.3
1414
ghp-import==2.1.0
1515
readme-renderer==37.3
1616
pymdown-extensions==9.10
17-
importlib-metadata==6.0.0
18-
pipdeptree==2.5.2
17+
importlib-metadata==6.1.0
18+
pipdeptree==2.6.0
1919
bleach==6.0.0
2020
lunr==0.6.2
2121
nltk==3.8.1
2222
tornado==6.2
23-
watchdog==2.3.1
23+
watchdog==3.0.0
2424
cairocffi==1.5.0
25-
cairosvg==2.6.0
25+
cairosvg==2.7.0
2626
cssselect2==0.7.0
2727
tinycss2==1.2.1
2828
defusedxml==0.7.1

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ sniffio==1.3.0;python_version>="3.7"
4141
h11==0.14.0;python_version>="3.7"
4242
outcome==1.2.0;python_version>="3.7"
4343
trio==0.22.0;python_version>="3.7"
44-
trio-websocket==0.10.0;python_version>="3.7"
44+
trio-websocket==0.10.2;python_version>="3.7"
4545
websockets==10.4;python_version>="3.7"
4646
pyopenssl==23.0.0;python_version>="3.7"
4747
wsproto==1.2.0;python_version>="3.7"
@@ -75,7 +75,7 @@ sbvirtualdisplay==1.2.0
7575
behave==1.2.6
7676
soupsieve==2.3.2.post1;python_version<"3.7"
7777
soupsieve==2.4;python_version>="3.7"
78-
beautifulsoup4==4.11.2
78+
beautifulsoup4==4.12.0
7979
cryptography==36.0.2;python_version<"3.7"
8080
cryptography==39.0.2;python_version>="3.7"
8181
pygments==2.14.0

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.13.15"
2+
__version__ = "4.13.16"

seleniumbase/console_scripts/run.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -717,15 +717,18 @@ def show_methods():
717717
sbm += "*.type(selector, text) => Update the field with the text.\n"
718718
sbm += "*.click(selector) => Click the element with the selector.\n"
719719
sbm += "*.click_link(link_text) => Click the link containing text.\n"
720-
sbm += "*.go_back() => Navigate back to the previous URL.\n"
720+
sbm += "*.check_if_unchecked(selector) => Check checkbox if unchecked.\n"
721+
sbm += "*.uncheck_if_checked(selector) => Uncheck checkbox if checked.\n"
721722
sbm += "*.select_option_by_text(dropdown_selector, option)\n"
722723
sbm += "*.hover_and_click(hover_selector, click_selector)\n"
723724
sbm += "*.drag_and_drop(drag_selector, drop_selector)\n"
725+
sbm += "*.choose_file(selector, file_path) => Choose a file to upload.\n"
724726
sbm += "*.get_text(selector) => Get the text from the element.\n"
725727
sbm += "*.get_current_url() => Get the URL of the current page.\n"
726728
sbm += "*.get_page_source() => Get the HTML of the current page.\n"
727729
sbm += "*.get_attribute(selector, attribute) => Get element attribute.\n"
728730
sbm += "*.get_title() => Get the title of the current page.\n"
731+
sbm += "*.go_back() => Navigate to the previous page in history.\n"
729732
sbm += "*.switch_to_frame(frame) => Switch into the iframe container.\n"
730733
sbm += "*.switch_to_default_content() => Exit all iframe containers.\n"
731734
sbm += "*.switch_to_parent_frame() => Exit from the current iframe.\n"
@@ -736,13 +739,20 @@ def show_methods():
736739
sbm += "*.switch_to_driver(driver) => Switch to the browser driver.\n"
737740
sbm += "*.switch_to_default_driver() => Switch to the original driver.\n"
738741
sbm += "*.wait_for_element(selector) => Wait until element is visible.\n"
742+
sbm += "*.wait_for_element_present(selector) => Until element in HTML.\n"
739743
sbm += "*.is_element_visible(selector) => Return element visibility.\n"
744+
sbm += "*.is_element_present(selector) => Return element is in HTML.\n"
740745
sbm += "*.is_text_visible(text, selector) => Return text visibility.\n"
746+
sbm += "*.is_checked(selector) => Return whether the box is checked.\n"
741747
sbm += "*.sleep(seconds) => Do nothing for the given amount of time.\n"
742748
sbm += "*.save_screenshot(name) => Save a screenshot in .png format.\n"
743749
sbm += "*.assert_element(selector) => Verify the element is visible.\n"
744750
sbm += "*.assert_text(text, selector) => Verify text in the element.\n"
751+
sbm += "*.assert_exact_text(text, selector) => Verify text is exact.\n"
752+
sbm += "*.assert_url(url) => Verify that the current URL is the URL.\n"
753+
sbm += "*.assert_url_contains(substring) => Verify substring in URL.\n"
745754
sbm += "*.assert_title(title) => Verify the title of the web page.\n"
755+
sbm += "*.assert_title_contains(substring) => Verify STR in title.\n"
746756
sbm += "*.assert_downloaded_file(file) => Verify file was downloaded.\n"
747757
sbm += "*.assert_no_404_errors() => Verify there are no broken links.\n"
748758
sbm += "*.assert_no_js_errors() => Verify there are no JS errors.\n"
@@ -769,15 +779,17 @@ def show_options():
769779
line = '(Some options are Chromium-specific, e.g. "--guest --mobile")'
770780
print(line)
771781
op = "\n"
772-
op += '--browser=BROWSER (The web browser to use. Default is "chrome")\n'
773-
op += "--headless (Run tests headlessly. Default mode on Linux OS.)\n"
782+
op += '--browser=BROWSER (Choice of web browser. Default is "chrome".)\n'
783+
op += "--edge / --firefox / --safari (Shortcut for browser selection.)\n"
784+
op += "--headless (Run tests headlessly. Default setting on Linux OS.)\n"
774785
op += "--demo (Slow down and visually see test actions as they occur.)\n"
775786
op += "--slow (Slow down the automation. Faster than using Demo Mode.)\n"
776787
op += "--reuse-session / --rs (Reuse browser session between tests.)\n"
788+
op += "--reuse-class-session / --rcs (RS, but for class tests only.)\n"
777789
op += "--crumbs (Clear all cookies between tests reusing a session.)\n"
778790
op += "--maximize (Start tests with the web browser window maximized.)\n"
779791
op += "--dashboard (Enable SeleniumBase's Dashboard at dashboard.html)\n"
780-
op += "--uc (Enable undetected-chromedriver to evade bot-detection.)\n"
792+
op += "--uc (Use undetected-chromedriver mode to evade bot-detection.)\n"
781793
op += "--incognito (Enable Chromium's Incognito mode.)\n"
782794
op += "--guest (Enable Chromium's Guest mode.)\n"
783795
op += "-m=MARKER (Run tests with the specified pytest marker.)\n"
@@ -794,10 +806,12 @@ def show_options():
794806
op += " | return / r: Run until method returns. j: Jump to line. |\n"
795807
op += " | where / w: Show stack spot. u: Up stack. d: Down stack. |\n"
796808
op += " | longlist / ll: See code. dir(): List namespace objects. |\n"
809+
op += "--help / -h (Display list of all available pytest options.)\n"
797810
op += "--final-debug (Enter Final Debug Mode after each test ends.)\n"
798-
op += "--recorder (Record browser actions to generate test scripts.)\n"
811+
op += "--recorder / --rec (Save browser actions as Python scripts.)\n"
812+
op += "--rec-behave / --rec-gherkin (Save actions as Gherkin code.)\n"
799813
op += "--save-screenshot (Save a screenshot at the end of each test.)\n"
800-
op += "--archive-logs (Archive old log files instead of deleting them.)\n"
814+
op += "--archive-logs (Archive logs after tests to prevent deletion.)\n"
801815
op += "--check-js (Check for JavaScript errors after page loads.)\n"
802816
op += "--start-page=URL (The browser start page when tests begin.)\n"
803817
op += "--agent=STRING (Modify the web browser's User-Agent string.)\n"

seleniumbase/core/browser_launcher.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,11 @@ def _set_firefox_options(
847847
)
848848
if headless and not IS_LINUX:
849849
options.add_argument("--headless")
850+
elif headless and IS_LINUX:
851+
# This assumes Xvfb is running, which prevents many Linux issues.
852+
# If not, we'll fix this later during the error-handling process.
853+
# To override this feature: ``pytest --firefox-arg="-headless"``.
854+
pass
850855
if locale_code:
851856
options.set_preference("intl.accept_languages", locale_code)
852857
options.set_preference("browser.shell.checkDefaultBrowser", False)
@@ -1972,10 +1977,18 @@ def get_local_driver(
19721977
or "A connection attempt failed" in e.msg
19731978
)
19741979
):
1975-
# Firefox probably just auto-updated itself,
1976-
# which causes intermittent issues to occur.
1977-
# Trying again right after that often works.
19781980
time.sleep(0.1)
1981+
if (
1982+
IS_LINUX
1983+
and headless
1984+
and (
1985+
"unexpected" in str(e)
1986+
or (
1987+
hasattr(e, "msg") and "unexpected" in e.msg
1988+
)
1989+
)
1990+
):
1991+
firefox_options.add_argument("-headless")
19791992
return webdriver.Firefox(
19801993
service=service,
19811994
options=firefox_options,
@@ -1993,7 +2006,8 @@ def get_local_driver(
19932006
service = FirefoxService(log_path=os.devnull)
19942007
try:
19952008
return webdriver.Firefox(
1996-
service=service, options=firefox_options
2009+
service=service,
2010+
options=firefox_options,
19972011
)
19982012
except BaseException as e:
19992013
if (
@@ -2008,10 +2022,18 @@ def get_local_driver(
20082022
or "A connection attempt failed" in e.msg
20092023
)
20102024
):
2011-
# Firefox probably just auto-updated itself,
2012-
# which causes intermittent issues to occur.
2013-
# Trying again right after that often works.
20142025
time.sleep(0.1)
2026+
if (
2027+
IS_LINUX
2028+
and headless
2029+
and (
2030+
"unexpected" in str(e)
2031+
or (
2032+
hasattr(e, "msg") and "unexpected" in e.msg
2033+
)
2034+
)
2035+
):
2036+
firefox_options.add_argument("-headless")
20152037
return webdriver.Firefox(
20162038
service=service,
20172039
options=firefox_options,

seleniumbase/plugins/pytest_plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1718,8 +1718,8 @@ def _create_dashboard_assets_():
17181718
def pytest_itemcollected(item):
17191719
if "--co" in sys_argv or "--collect-only" in sys_argv:
17201720
return
1721+
sb_config.item_count += 1
17211722
if sb_config.dashboard:
1722-
sb_config.item_count += 1
17231723
test_id, display_id = _get_test_ids_(item)
17241724
sb_config._results[test_id] = "Untested"
17251725
sb_config._duration[test_id] = "-"

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
'h11==0.14.0;python_version>="3.7"',
166166
'outcome==1.2.0;python_version>="3.7"',
167167
'trio==0.22.0;python_version>="3.7"',
168-
'trio-websocket==0.10.0;python_version>="3.7"',
168+
'trio-websocket==0.10.2;python_version>="3.7"',
169169
'websockets==10.4;python_version>="3.7"',
170170
'pyopenssl==23.0.0;python_version>="3.7"',
171171
'wsproto==1.2.0;python_version>="3.7"',
@@ -199,7 +199,7 @@
199199
"behave==1.2.6",
200200
'soupsieve==2.3.2.post1;python_version<"3.7"',
201201
'soupsieve==2.4;python_version>="3.7"',
202-
"beautifulsoup4==4.11.2",
202+
"beautifulsoup4==4.12.0",
203203
'cryptography==36.0.2;python_version<"3.7"',
204204
'cryptography==39.0.2;python_version>="3.7"',
205205
"pygments==2.14.0",

0 commit comments

Comments
 (0)