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

Migrate to Browser library #1176

Open
jiridanek opened this issue Feb 5, 2024 · 2 comments
Open

Migrate to Browser library #1176

jiridanek opened this issue Feb 5, 2024 · 2 comments

Comments

@jiridanek
Copy link
Member

jiridanek commented Feb 5, 2024

This was discussed on Automation meeting and on internal slack. Originally proposed by @tarukumar.

https://robotframework-browser.org/

Browser is incompatible with kfp

kfp (1.8.21) depends on protobuf (>=3.13.0,<4)
and robotframework-browser (18.0.0) depends on protobuf (4.25.1)

There is no easy solution, https://stackoverflow.com/questions/77939981/how-to-handle-diamond-dependency-in-python/77940013

Missing waits

When logging into OpenShift, we do

${oauth_prompt_visible} =  Is OpenShift OAuth Login Prompt Visible
   IF  ${oauth_prompt_visible}       Click Button  Log in with OpenShift
   ${login-required} =  Is OpenShift Login Visible
...

The problem is that Browser is too fast and it runs the Is OpenShift Login Visible before the page is reloaded after Click Button

Strict mode

Browser library will fail the test if locators match more than a single element. https://playwright.dev/docs/locators#strictness

Exception has occurred.
Suspended due to logged failure: Error: locator.waitFor: Error: strict mode violation: locator('//input[contains(@id, "minimal-notebook")]') resolved to 3 elements:
    1) <input type="radio" aria-invalid="false" name="Minimal …/> aka getByLabel('Minimal Python2023.2')
    2) <input type="radio" aria-invalid="false" data-ouia-safe…/> aka locator('[id="s2i-minimal-notebook\\:2023\\.2"]')
    3) <input type="radio" aria-invalid="false" data-ouia-safe…/> aka locator('[id="s2i-minimal-notebook\\:2023\\.1"]')

Call log:
  �[2m- waiting for locator('//input[contains(@id, "minimal-notebook")]')�[22m

robotframework-browser-migration is not a drop-in replacement

I had hight hopes for https://pypi.org/project/robotframework-browser-migration. Sadly, it does not magically work when I put it in. Instead, the issues above appear, plus additional test failures not yet understood.

@jiridanek
Copy link
Member Author

jiridanek commented Feb 5, 2024

I've fixed few of the tests in smoke, job/rhoai/job/2.6/job/selfmanaged/job/stage/job/aws/job/rhods-smoke/44/

So far, I'm not excited about Browser. The effort to migrate will not be small.

@jiridanek
Copy link
Member Author

Here's a bit more details about https://pypi.org/project/robotframework-browser-migration. They implement Selenium keywords in terms of Playwright keywords, so ideally, the migration is just

find ./ -type f -name "*.robot" -print0 | xargs -0 sed -i s/SeleniumLibrary/SeleniumLibraryToBrowser/g

There is one change, browser arguments for playwright must be given as array of strings, and not as a single string. Other than that, --dryrun works.

They have a tool to give you stats on what keywords from selenium you use.

poetry add robotframework-browser-migration
poetry run robot --dryrun -r test_report.html --variablefile ods_ci/test-variables.yml ods_ci/tests/Tests
python -m SeleniumStats output.xml
reading results from: /home/jdanek/repos/ods-ci/output.xml
+------------------------------------------+-------+---------+------------------+
| Keyword                                  | count | parents | migration status |
+------------------------------------------+-------+---------+------------------+
| Capture Page Screenshot                  | 2331  | 64      |                  |
| Checkbox Should Be Selected              | 497   | 5       |                  |
| Choose File                              | 32    | 3       |                  |
| Clear Element Text                       | 114   | 4       |                  |
| Click Button                             | 3018  | 82      |                  |
| Click Element                            | 13724 | 169     |                  |
| Click Link                               | 810   | 31      |                  |
| Close All Browsers                       | 99    | 43      |                  |
| Close Browser                            | 72    | 23      |                  |
| Close Window                             | 2     | 2       |                  |
| Element Attribute Value Should Be        | 174   | 2       |                  |
| Element Should Be Disabled               | 195   | 13      |                  |
| Element Should Be Enabled                | 268   | 7       |                  |
| Element Should Be Visible                | 237   | 3       |                  |
| Element Should Contain                   | 1     | 1       |                  |
| Element Should Not Be Visible            | 185   | 3       |                  |
| Element Text Should Be                   | 33    | 4       |                  |
| Execute Javascript                       | 1040  | 4       |                  |
| Get Browser Ids                          | 2     | 2       |                  |
| Get Cookie                               | 2     | 1       |                  |
| Get Element Attribute                    | 2538  | 34      |                  |
| Get Element Count                        | 106   | 5       |                  |
| Get Location                             | 1024  | 2       |                  |
| Get Text                                 | 766   | 48      |                  |
| Get Title                                | 477   | 4       |                  |
| Get Value                                | 216   | 5       |                  |
| Get Webelement                           | 1414  | 8       |                  |
| Get Webelements                          | 4376  | 32      |                  |
| Get Window Handles                       | 1     | 1       |                  |
| Go To                                    | 82    | 21      |                  |
| Input Text                               | 2180  | 55      |                  |
| Location Should Contain                  | 106   | 3       |                  |
| Mouse Over                               | 4706  | 4       |                  |
| Open Browser                             | 250   | 27      |                  |
| Open Context Menu                        | 1     | 1       |                  |
| Page Should Contain                      | 3447  | 15      |                  |
| Page Should Contain Button               | 5     | 2       |                  |
| Page Should Contain Element              | 3115  | 32      |                  |
| Page Should Contain Link                 | 30    | 1       |                  |
| Page Should Not Contain                  | 105   | 13      |                  |
| Page Should Not Contain Element          | 256   | 10      |                  |
| Page Should Not Contain Link             | 7     | 1       |                  |
| Press Keys                               | 55    | 13      |                  |
| Reload Page                              | 556   | 27      |                  |
| Select Checkbox                          | 40    | 6       |                  |
| Select Frame                             | 3     | 3       |                  |
| Set Selenium Implicit Wait               | 4     | 2       |                  |
| Switch Browser                           | 33    | 6       |                  |
| Switch Window                            | 493   | 16      |                  |
| Unselect Checkbox                        | 15    | 3       |                  |
| Unselect Frame                           | 3     | 3       |                  |
| Wait For Condition                       | 758   | 2       |                  |
| Wait Until Element Is Enabled            | 242   | 16      |                  |
| Wait Until Element Is Not Visible        | 514   | 1       |                  |
| Wait Until Element Is Visible            | 1156  | 25      |                  |
| Wait Until Page Contains                 | 3885  | 67      |                  |
| Wait Until Page Contains Element         | 6664  | 123     |                  |
| Wait Until Page Does Not Contain         | 9     | 2       |                  |
| Wait Until Page Does Not Contain Element | 1527  | 20      |                  |
+------------------------------------------+-------+---------+------------------+

Statistics File: /home/jdanek/repos/ods-ci/keyword_stats.json
Please upload the file to https://data.keyword-driven.de/index.php/s/SeleniumStats for full anonymity.
IP-Addresses or other personal data are not logged when uploading the file!
You can also mail it to mailto:[email protected].

Thank you very much for your support!
Your Browser-Team (Mikko, Tatu, Kerkko, Janne and René)

As I already said above, while the tests run, they end up failing, for various reasons, such as incompatibilities the library does not paper over, and various different behaviors, such as the login thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant