Skip to content
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

Update test under python versions #1862

Merged
30 changes: 14 additions & 16 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ jobs:
build:

runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
python-version: [3.7, 3.9, pypy-3.7]
python-version: [3.8, 3.11] # 3.12, pypy-3.9
rf-version: [4.1.3, 5.0.1, 6.0.1]

steps:
Expand All @@ -35,7 +36,7 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Install dependencies for pypy
if: matrix.python-version == 'pypy-3.7'
if: matrix.python-version == 'pypy-3.9'
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
Expand All @@ -51,24 +52,21 @@ jobs:
echo "WEBDRIVERPATH=$($SELENIUM_MANAGER_EXE --browser chrome --debug | awk '/INFO[[:space:]]Driver path:/ {print $NF;exit}')" >> "$GITHUB_ENV"
echo "$WEBDRIVERPATH"
- name: Generate stub file for ${{ matrix.python-version }}
if: matrix.python-version != 'pypy-3.7'
if: matrix.python-version != 'pypy-3.9'
run: |
invoke gen-stub
- name: Debugging
if: matrix.python-version != 'pypy-3.7'
run: |
which python

- name: Run tests with headless Chrome and with PyPy
if: matrix.python-version == 'pypy-3.7'
if: matrix.python-version == 'pypy-3.9'
run: |
xvfb-run --auto-servernum python atest/run.py --nounit --zip headlesschrome

- name: Run tests with normal Chrome and with Python 3.7
if: matrix.python-version == '3.7'
- name: Run tests with normal Chrome if CPython
if: matrix.python-version != 'pypy-3.9'
run: |
xvfb-run --auto-servernum python atest/run.py --zip chrome

# Recognize for the moment this will NOT run as we aren't using Python 3.9
- name: Run tests with headless Firefox with Python 3.9 and RF 4.1.3
if: matrix.python-version == '3.9' && matrix.rf-version == '4.1.3'
run: |
Expand All @@ -79,12 +77,12 @@ jobs:
run: |
xvfb-run --auto-servernum python atest/run.py --zip firefox

- name: Run tests with Selenium Grid
if: matrix.python-version == '3.8' && matrix.rf-version == '3.2.2' && matrix.python-version != 'pypy-3.7'
run: |
wget --no-verbose --output-document=./selenium-server-standalone.jar http://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar
sudo chmod u+x ./selenium-server-standalone.jar
xvfb-run --auto-servernum python atest/run.py --zip headlesschrome --grid True
# - name: Run tests with Selenium Grid
# if: matrix.python-version == '3.11' && matrix.rf-version == '3.2.2' && matrix.python-version != 'pypy-3.7'
# run: |
# wget --no-verbose --output-document=./selenium-server-standalone.jar http://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar
# sudo chmod u+x ./selenium-server-standalone.jar
# xvfb-run --auto-servernum python atest/run.py --zip headlesschrome --grid True

- uses: actions/upload-artifact@v1
if: success() || failure()
Expand Down
4 changes: 2 additions & 2 deletions atest/acceptance/create_webdriver.robot
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Library Collections
Create Webdriver Creates Functioning WebDriver
[Documentation]
... LOG 1:1 INFO REGEXP: Creating an instance of the \\w+ WebDriver.
... LOG 1:25 DEBUG REGEXP: Created \\w+ WebDriver instance with session id (\\w|-)+.
... LOG 1:19 DEBUG REGEXP: Created \\w+ WebDriver instance with session id (\\w|-)+.
[Tags] Known Issue Internet Explorer Known Issue Safari
[Setup] Set Driver Variables
Create Webdriver ${DRIVER_NAME} kwargs=${KWARGS}
Expand All @@ -30,7 +30,7 @@ Create Webdriver With Bad Keyword Argument Dictionary
[Documentation] Invalid arguments types
${status} ${error} = Run Keyword And Ignore Error Create Webdriver Firefox kwargs={'spam': 'eggs'}
Should Be Equal ${status} FAIL
Should Match Regexp ${error} (TypeError: __init__\\(\\) got an unexpected keyword argument 'spam'|kwargs must be a dictionary\.)
Should Match Regexp ${error} (TypeError: (?:WebDriver.)?__init__\\(\\) got an unexpected keyword argument 'spam'|kwargs must be a dictionary\.)

*** Keywords ***
Set Driver Variables
Expand Down
2 changes: 1 addition & 1 deletion atest/acceptance/keywords/choose_file.robot
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Choose File With Grid From Library Using SL choose_file method

Input Text Should Work Same Way When Not Using Grid
[Documentation]
... LOG 1:6 DEBUG GLOB: POST*/session/*/clear {"*
... LOG 1:6 DEBUG GLOB: POST*/session/*/clear {*
... LOG 1:9 DEBUG Finished Request
... LOG 1:10 DEBUG GLOB: POST*/session/*/value*"text": "*
... LOG 1:13 DEBUG Finished Request
Expand Down
12 changes: 6 additions & 6 deletions atest/acceptance/keywords/content_assertions.robot
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Page Should Contain Using Default Custom Log Level
... 'TRACE' - noting the excluded second argument for the `Page Should Contain`
... keyword) fails and the log contains the html content.
... FAIL Page should have contained text 'non existing text' but did not.
... LOG 2:19 TRACE REGEXP: (?i)<html.*</html>
... LOG 2:19 TRACE REGEXP: <html.*</html>
... LOG 2:20 FAIL Page should have contained text 'non existing text' but did not.
${old_level}= Set Log Level TRACE
Page Should Contain non existing text
Expand All @@ -53,31 +53,31 @@ Page Should Contain With Custom Log Level INFO
[Tags] NoGrid
[Documentation] Html content is shown at the explicitly specified INFO level.
... FAIL Page should have contained text 'non existing text' but did not.
... LOG 1:18 INFO REGEXP: (?i)<html.*</html>
... LOG 1:18 INFO REGEXP: <html.*</html>
... LOG 1:19 FAIL Page should have contained text 'non existing text' but did not.
Page Should Contain non existing text INFO

Page Should Contain With Custom Log Level WARN
[Tags] NoGrid
[Documentation] Html content is shown at the explicitly specified WARN level.
... FAIL Page should have contained text 'non existing text' but did not.
... LOG 1:18 WARN REGEXP: (?i)<html.*</html>
... LOG 1:18 WARN REGEXP: <html.*</html>
... LOG 1:19 FAIL Page should have contained text 'non existing text' but did not.
Page Should Contain non existing text WARN

Page Should Contain With Custom Log Level DEBUG
[Tags] NoGrid
[Documentation] Html content is shown at the explicitly specified DEBUG level.
... FAIL Page should have contained text 'non existing text' but did not.
... LOG 1:18 DEBUG REGEXP: (?i)<html.*</html>
... LOG 1:18 DEBUG REGEXP: <html.*</html>
... LOG 1:19 FAIL Page should have contained text 'non existing text' but did not.
Page Should Contain non existing text DEBUG

Page Should Contain With Custom Log Level TRACE
[Tags] NoGrid
[Documentation] Html content is shown at the explicitly specified TRACE level.
... FAIL Page should have contained text 'non existing text' but did not.
... LOG 2:19 TRACE REGEXP: (?i)<html.*</html>
... LOG 2:19 TRACE REGEXP: <html.*</html>
... LOG 2:20 FAIL Page should have contained text 'non existing text' but did not.
Set Log Level TRACE
Page Should Contain non existing text TRACE
Expand Down Expand Up @@ -122,7 +122,7 @@ Page Should Not Contain

Page Should Not Contain With Custom Log Level
[Tags] NoGrid
[Documentation] LOG 1.1:13 DEBUG REGEXP: (?i)<html.*</html>
[Documentation] LOG 1.1:13 DEBUG REGEXP: <html.*</html>
Run Keyword And Expect Error
... Page should not have contained text 'needle'.
... Page Should Not Contain needle DEBUG
Expand Down
7 changes: 3 additions & 4 deletions atest/acceptance/keywords/page_load_timeout.robot
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ Test Teardown Close Browser And Reset Page Load Timeout
*** Test Cases ***
Should Open Browser With Default Page Load Timeout
[Documentation] Verify that 'Open Browser' changes the page load timeout.
... LOG 1.1.1:33 DEBUG REGEXP: POST http://localhost:\\d{2,5}/session/[a-f0-9-]+/timeouts {"pageLoad": 300000}
... LOG 1.1.1:35 DEBUG STARTS: Remote response: status=200
# ... LOG 1.1.1:16 DEBUG REGEXP: POST http://localhost:\\d{2,5}/session/[a-f0-9-]+/timeouts {"pageLoad": 300000}
# ... LOG 1.1.1:18 DEBUG STARTS: Remote response: status=200
... LOG 1.1.1:27 DEBUG REGEXP: POST http://localhost:\\d{2,5}/session/[a-f0-9-]+/timeouts {"pageLoad": 300000}
... LOG 1.1.1:29 DEBUG STARTS: Remote response: status=200
# Note: previous log check was 33 and 37. Recording to see if something is swtiching back and forth
Open Browser To Start Page

Should Run Into Timeout Exception
Expand Down
6 changes: 3 additions & 3 deletions atest/acceptance/multiple_browsers_options.robot
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Chrome Browser With Selenium Options As String
... desired_capabilities=${DESIRED_CAPABILITIES} options=add_argument("--disable-dev-shm-usage")
... executable_path=%{WEBDRIVERPATH}

Chrome Browser With Selenium Options As String With Attirbute As True
Chrome Browser With Selenium Options As String With Attribute As True
[Documentation]
... LOG 1:3 DEBUG GLOB: *"goog:chromeOptions"*
... LOG 1:3 DEBUG GLOB: *args": ["--disable-dev-shm-usage"?*
... LOG 1:3 DEBUG GLOB: *"--headless"*
... LOG 1:3 DEBUG GLOB: *"--headless=new"*
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
... desired_capabilities=${DESIRED_CAPABILITIES} options=add_argument ( "--disable-dev-shm-usage" ) ; headless = True
... desired_capabilities=${DESIRED_CAPABILITIES} options=add_argument ( "--disable-dev-shm-usage" ) ; add_argument ( "--headless=new" )
... executable_path=%{WEBDRIVERPATH}

Chrome Browser With Selenium Options With Complex Object
Expand Down
10 changes: 6 additions & 4 deletions atest/acceptance/multiple_browsers_service_log_path.robot
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,22 @@ First Browser With Service Log Path
[Documentation]
... LOG 1:2 INFO STARTS: Browser driver log file created to:
[Setup] OperatingSystem.Remove Files ${OUTPUT DIR}/${BROWSER}.log
Open Browser ${FRONT PAGE} ${BROWSER} service_log_path=${BROWSER}.log
Open Browser ${FRONT PAGE} ${BROWSER} service_log_path=${OUTPUT DIR}/${BROWSER}.log
OperatingSystem.List Directories In Directory ${OUTPUT DIR}/
${output}= OperatingSystem.Run ls -lh
OperatingSystem.File Should Not Be Empty ${OUTPUT DIR}/${BROWSER}.log

Second Browser With Service Log Path And Index
[Setup] OperatingSystem.Remove Files ${OUTPUT DIR}/${BROWSER}-1.log
Open Browser ${FRONT PAGE} ${BROWSER} service_log_path=${BROWSER}-{index}.log
Open Browser ${FRONT PAGE} ${BROWSER} service_log_path=${OUTPUT DIR}/${BROWSER}-{index}.log
OperatingSystem.File Should Not Be Empty ${OUTPUT DIR}/${BROWSER}-1.log

Third Browser With Service Log Path And Index Should Not Overwrite
[Setup] OperatingSystem.Remove Files ${OUTPUT DIR}/${BROWSER}-2.log
Open Browser ${FRONT PAGE} ${BROWSER} service_log_path=${BROWSER}-{index}.log
Open Browser ${FRONT PAGE} ${BROWSER} service_log_path=${OUTPUT DIR}/${BROWSER}-{index}.log
OperatingSystem.File Should Not Be Empty ${OUTPUT DIR}/${BROWSER}-2.log

Fourth Browser With Service Log Path In Subfolder
[Setup] OperatingSystem.Remove Files ${OUTPUT DIR}/a_folder/${BROWSER}-1.log
Open Browser ${FRONT PAGE} ${BROWSER} service_log_path=a_folder/${BROWSER}-{index}.log
Open Browser ${FRONT PAGE} ${BROWSER} service_log_path=${OUTPUT DIR}/a_folder/${BROWSER}-{index}.log
OperatingSystem.File Should Not Be Empty ${OUTPUT DIR}/a_folder/${BROWSER}-1.log
10 changes: 9 additions & 1 deletion src/SeleniumLibrary/keywords/webdrivertools/webdrivertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,15 @@ def create_chrome(
return self._remote(remote_url, options=options)
if not executable_path:
executable_path = self._get_executable_path(webdriver.chrome.service.Service)
service = ChromeService(executable_path=executable_path, log_path=service_log_path)
# -- temporary fix to transition selenium to v4.13 from v4.11 and prior
from inspect import signature
sig = signature(ChromeService)
if 'log_output' in str(sig):
log_method = {'log_output': service_log_path}
else:
log_method = {'log_path': service_log_path}
# --
service = ChromeService(executable_path=executable_path, **log_method)
return webdriver.Chrome(
options=options,
service=service,
Expand Down