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 atests with preconfigured webdriver #1861

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Setup Chrome
uses: browser-actions/setup-chrome@latest
with:
chrome-version: latest
id: setup-chrome
- run: |
echo Installed chromium version: ${{ steps.setup-chrome.outputs.chrome-version }}
${{ steps.setup-chrome.outputs.chrome-path }} --version
- name: Start xvfb
run: |
export DISPLAY=:99.0
Expand All @@ -36,6 +44,12 @@ jobs:
- name: Install RF ${{ matrix.rf-version }}
run: |
pip install -U --pre robotframework==${{ matrix.rf-version }}
- name: Install drivers via selenium-manager
run: |
SELENIUM_MANAGER_EXE=$(python -c 'from selenium.webdriver.common.selenium_manager import SeleniumManager; sm=SeleniumManager(); print(f"{str(sm.get_binary())}")')
echo "$SELENIUM_MANAGER_EXE"
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'
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Library SeleniumLibrary event_firing_webdriver=${CURDIR}/../../resources/testlibs/MyListener.py
Resource resource_event_firing_webdriver.robot
Suite Setup Open Browser ${FRONT PAGE} ${BROWSER} alias=event_firing_webdriver
... remote_url=${REMOTE_URL} desired_capabilities=${DESIRED_CAPABILITIES}
... remote_url=${REMOTE_URL} executable_path=%{WEBDRIVERPATH}
Suite Teardown Close All Browsers

*** Variables ***
Expand All @@ -15,7 +15,7 @@ Open Browser To Start Page
... LOG 1:20 DEBUG Wrapping driver to event_firing_webdriver.
... LOG 1:22 INFO Got driver also from SeleniumLibrary.
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
... desired_capabilities=${DESIRED_CAPABILITIES}
... executable_path=%{WEBDRIVERPATH}

Event Firing Webdriver Go To (WebDriver)
[Tags] NoGrid
Expand Down
2 changes: 1 addition & 1 deletion 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:8 DEBUG REGEXP: Created \\w+ WebDriver instance with session id (\\w|-)+.
... LOG 1:25 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 Down
40 changes: 23 additions & 17 deletions atest/acceptance/keywords/cookies.robot
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Suite Setup Go To Page "cookies.html"
Suite Teardown Delete All Cookies
Test Setup Add Cookies
Resource ../resource.robot
Library DateTime

*** Test Cases ***
Get Cookies
Expand All @@ -13,7 +14,7 @@ Get Cookies

Get Cookies As Dict
${cookies}= Get Cookies as_dict=True
${expected_cookies}= Create Dictionary test=seleniumlibrary another=value
${expected_cookies}= Create Dictionary test=seleniumlibrary another=value far_future=timemachine
Dictionaries Should Be Equal ${expected_cookies} ${cookies}

App Sees Cookie Set By Selenium
Expand All @@ -35,21 +36,21 @@ Add Cookie When Secure Is False
Should Be Equal ${cookie.secure} ${False}

Add Cookie When Expiry Is Epoch
Add Cookie Cookie1 value1 expiry=1698601011
Add Cookie Cookie1 value1 expiry=1730205247
${cookie} = Get Cookie Cookie1
${expiry} = Convert Date ${1698601011} exclude_millis=True
${expiry} = Convert Date ${1730205247} exclude_millis=True
Should Be Equal As Strings ${cookie.expiry} ${expiry}

Add Cookie When Expiry Is Human Readable Data&Time
Add Cookie Cookie12 value12 expiry=2023-10-29 19:36:51
Add Cookie Cookie12 value12 expiry=2024-10-29 19:36:51
${cookie} = Get Cookie Cookie12
Should Be Equal As Strings ${cookie.expiry} 2023-10-29 19:36:51
Should Be Equal As Strings ${cookie.expiry} 2024-10-29 19:36:51

Delete Cookie
[Tags] Known Issue Safari
Delete Cookie test
${cookies} = Get Cookies
Should Be Equal ${cookies} another=value
Should Be Equal ${cookies} far_future=timemachine; another=value

Non-existent Cookie
Run Keyword And Expect Error
Expand All @@ -71,12 +72,12 @@ Get Cookies As Dict When There Are None

Test Get Cookie Object Expiry
${cookie} = Get Cookie another
Should Be Equal As Integers ${cookie.expiry.year} 2023
Should Be Equal As Integers ${cookie.expiry.month} 10
Should Be Equal As Integers ${cookie.expiry.day} 29
Should Be Equal As Integers ${cookie.expiry.hour} 19
Should Be Equal As Integers ${cookie.expiry.minute} 36
Should Be Equal As Integers ${cookie.expiry.second} 51
Should Be Equal As Integers ${cookie.expiry.year} ${tomorrow_thistime_datetime.year}
Should Be Equal As Integers ${cookie.expiry.month} ${tomorrow_thistime_datetime.month}
Should Be Equal As Integers ${cookie.expiry.day} ${tomorrow_thistime_datetime.day}
Should Be Equal As Integers ${cookie.expiry.hour} ${tomorrow_thistime_datetime.hour}
Should Be Equal As Integers ${cookie.expiry.minute} ${tomorrow_thistime_datetime.minute}
Should Be Equal As Integers ${cookie.expiry.second} ${tomorrow_thistime_datetime.second}
Should Be Equal As Integers ${cookie.expiry.microsecond} 0

Test Get Cookie Object Domain
Expand Down Expand Up @@ -106,18 +107,23 @@ Test Get Cookie Object Value
Test Get Cookie Keyword Logging
[Tags] NoGrid Known Issue Firefox
[Documentation]
... LOG 1:5 ${cookie} = name=another
... value=value
... LOG 1:5 ${cookie} = name=far_future
... value=timemachine
... path=/
... domain=localhost
... secure=False
... httpOnly=False
... expiry=2023-10-29 19:36:51
... expiry=2024-09-15 11:22:33
... extra={'sameSite': 'Lax'}
${cookie} = Get Cookie another
${cookie} = Get Cookie far_future

*** Keyword ***
Add Cookies
Delete All Cookies
Add Cookie test seleniumlibrary
Add Cookie another value expiry=2023-10-29 19:36:51
${now} = Get Current Date
${tomorrow_thistime} = Add Time To Date ${now} 1 day
${tomorrow_thistime_datetime} = Convert Date ${tomorrow_thistime} datetime
Set Suite Variable ${tomorrow_thistime_datetime}
Add Cookie another value expiry=${tomorrow_thistime}
Add Cookie far_future timemachine expiry=1726399353 # 2024-09-15 11:22:33
6 changes: 4 additions & 2 deletions atest/acceptance/keywords/page_load_timeout.robot
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ 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: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: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
Open Browser To Start Page

Should Run Into Timeout Exception
Expand Down
6 changes: 6 additions & 0 deletions atest/acceptance/multiple_browsers_options.robot
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Chrome Browser With Selenium Options As String
... LOG 1:3 DEBUG GLOB: *args": ["--disable-dev-shm-usage"?*
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
... 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
[Documentation]
Expand All @@ -21,6 +22,7 @@ Chrome Browser With Selenium Options As String With Attirbute As True
... LOG 1:3 DEBUG GLOB: *"--headless"*
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
... desired_capabilities=${DESIRED_CAPABILITIES} options=add_argument ( "--disable-dev-shm-usage" ) ; headless = True
... executable_path=%{WEBDRIVERPATH}

Chrome Browser With Selenium Options With Complex Object
[Tags] NoGrid
Expand All @@ -30,6 +32,7 @@ Chrome Browser With Selenium Options With Complex Object
... LOG 1:3 DEBUG GLOB: *args": ["--disable-dev-shm-usage"?*
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
... desired_capabilities=${DESIRED_CAPABILITIES} options=add_argument ( "--disable-dev-shm-usage" ) ; add_experimental_option( "mobileEmulation" , { 'deviceName' : 'Galaxy S5'})
... executable_path=%{WEBDRIVERPATH}

Chrome Browser With Selenium Options Object
[Documentation]
Expand All @@ -38,11 +41,13 @@ Chrome Browser With Selenium Options Object
${options} = Get Chrome Options
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
... desired_capabilities=${DESIRED_CAPABILITIES} options=${options}
... executable_path=%{WEBDRIVERPATH}

Chrome Browser With Selenium Options Invalid Method
Run Keyword And Expect Error AttributeError: 'Options' object has no attribute 'not_here_method'
... Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
... desired_capabilities=${DESIRED_CAPABILITIES} options=not_here_method("arg1")
... executable_path=%{WEBDRIVERPATH}


Chrome Browser With Selenium Options Argument With Semicolon
Expand All @@ -51,3 +56,4 @@ Chrome Browser With Selenium Options Argument With Semicolon
... LOG 1:3 DEBUG GLOB: *["has;semicolon"*
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
... desired_capabilities=${DESIRED_CAPABILITIES} options=add_argument("has;semicolon")
... executable_path=%{WEBDRIVERPATH}
2 changes: 1 addition & 1 deletion atest/acceptance/open_and_close.robot
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Browser Open With Not Well-Formed URL Should Close
... LOG 1.1:24 DEBUG REGEXP: .*but failed to open url.*
... LOG 2:2 DEBUG STARTS: DELETE
... LOG 2:5 DEBUG STARTS: Finished Request
Run Keyword And Expect Error * Open Browser bad.url.bad ${BROWSER}
Run Keyword And Expect Error * Open Browser bad.url.bad ${BROWSER} executable_path=%{WEBDRIVERPATH}
Close All Browsers

Switch to closed browser is possible
Expand Down
Loading