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

[dotnet] implement WebDriver BiDi #14012

Closed
wants to merge 15 commits into from
Closed

Conversation

titusfortner
Copy link
Member

Status

This is in Draft so we can discuss what the API could look like
The PR is overly complicated because it relies on #13952 & #14010 so those must be merged first; can tidy it up after merging those (and if you want to hold off on reviewing it until then, that's fine, too).

Description

  • Adds the WebDriver BiDi dependency from Jim
  • BiDi is disabled in tests by default
  • Starts a BiDi session if webSocketUrl is set
  • Implements all the Navigation commands with conditionals for whether BiDi is present

Motivation and Context

This should be the easiest way to have working BiDi implementation in .NET since Jim has already written all the lower level commands (and would love not to duplicate that effort if we don't have to)
The conditionals in each method are not the most elegant, but they are straightforward, and I think that's preferred.
It'll be easy enough to just remove the conditionals when we remove support for WebDriver classic (Selenium 6?)

Considerations

We still need to implement updating browsingContextId when windows are switched, and figure out how navigation works if the browser context is a frame (recursively get parent?)

Figure out a better way to toggle BiDi with Bazel; I foresee us running tests with it toggled on and off, and I'm not sure an environment variable is the right way to do it. (@p0deje probably knows how to allow adding a flag for this)

@YevgeniyShunevych your input is appreciated as well

@titusfortner titusfortner added C-dotnet C-devtools BiDi or Chrome DevTools related issues labels May 22, 2024
Copy link

codiumai-pr-agent-pro bot commented May 22, 2024

CI Failure Feedback 🧐

(Checks updated until commit fcb4798)

Action: .NET / Build / Build

Failed stage: Run Bazel [❌]

Failure summary:

The action failed because the C# compilation process encountered multiple errors due to missing type
or namespace references. Specifically:

  • The type or namespace name WebDriverBiDi could not be found in Navigator.cs and WebDriver.cs.
  • The type or namespace name BiDiDriver could not be found in WebDriver.cs.
  • The type or namespace name ReadinessState could not be found in Navigator.cs.

  • Relevant error logs:
    1:  ##[group]Operating System
    2:  Microsoft Windows Server 2022
    ...
    
    772:  �[32m[1,708 / 1,825]�[0m Checking 1 JS files in @@io_bazel_rules_closure//closure/library/editor/plugins:linkshortcutplugin; 0s worker ... (4 actions, 3 running)
    773:  �[32m[1,759 / 1,825]�[0m Checking 1 JS files in @@io_bazel_rules_closure//closure/library/datasource:xmldatasource; 0s worker ... (4 actions running)
    774:  �[32m[1,800 / 1,825]�[0m Checking 27 JS files in @@//third_party/js/wgxpath:wgxpath; 0s worker ... (3 actions, 2 running)
    775:  �[32m[1,807 / 1,825]�[0m Compiling 659 JavaScript files to javascript/webdriver/atoms/get-attribute.js; 1s worker ... (3 actions running)
    776:  �[32m[1,807 / 1,825]�[0m Compiling 659 JavaScript files to javascript/webdriver/atoms/get-attribute.js; 18s worker ... (3 actions running)
    777:  �[32m[1,808 / 1,825]�[0m Compiling 663 JavaScript files to javascript/atoms/fragments/is-displayed.js; 35s worker ... (2 actions running)
    778:  �[32m[1,809 / 1,825]�[0m Compiling 698 JavaScript files to javascript/atoms/fragments/find-elements.js; 36s worker
    779:  �[32m[1,810 / 1,825]�[0m Compiling webdriver (internals ref-only dll); 0s local ... (3 actions running)
    780:  �[31m�[1mERROR: �[0mD:/a/selenium/selenium/dotnet/src/webdriver/BUILD.bazel:28:15: Compiling webdriver (internals ref-only dll) failed: (Exit 1): compiler_wrapper.bat failed: error executing CSharpCompile command (from target //dotnet/src/webdriver:webdriver) 
    781:  dotnet\src\webdriver\Navigator.cs(23,7): error CS0246: The type or namespace name 'WebDriverBiDi' could not be found (are you missing a using directive or an assembly reference?)
    782:  cd /d D:/_bazel/execroot/_main
    783:  dotnet\src\webdriver\WebDriver.cs(28,7): error CS0246: The type or namespace name 'WebDriverBiDi' could not be found (are you missing a using directive or an assembly reference?)
    784:  SET DOTNET_CLI_HOME=external/rules_dotnet~~dotnet~dotnet_x86_64-pc-windows-msvc
    785:  dotnet\src\webdriver\WebDriver.cs(29,7): error CS0246: The type or namespace name 'WebDriverBiDi' could not be found (are you missing a using directive or an assembly reference?)
    786:  external\rules_dotnet~\dotnet\private\compiler_wrapper.bat external/rules_dotnet~~dotnet~dotnet_x86_64-pc-windows-msvc/dotnet.exe external/rules_dotnet~~dotnet~dotnet_x86_64-pc-windows-msvc/sdk/7.0.400/Roslyn/bincore/csc.dll @bazel-out/x64_windows-fastbuild-ST-e0f67d5323b6/bin/dotnet/src/webdriver/webdriver/netstandard2.0/ref/WebDriver.dll-0.params
    787:  dotnet\src\webdriver\WebDriver.cs(1055,18): error CS0246: The type or namespace name 'BiDiDriver' could not be found (are you missing a using directive or an assembly reference?)
    788:  # Configuration: b5755e686b8da3c127445e15ff2d039eb80cab83ec512e99d1401cc3eec588cd
    789:  dotnet\src\webdriver\Navigator.cs(33,52): error CS0246: The type or namespace name 'ReadinessState' could not be found (are you missing a using directive or an assembly reference?)
    790:  # Execution platform: @@local_config_platform//:host
    791:  dotnet\src\webdriver\Navigator.cs(40,17): error CS0246: The type or namespace name 'ReadinessState' could not be found (are you missing a using directive or an assembly reference?)
    792:  dotnet\src\webdriver\WebDriver.cs(52,17): error CS0246: The type or namespace name 'BiDiDriver' could not be found (are you missing a using directive or an assembly reference?)
    793:  �[31m�[1mERROR: �[0mD:/a/selenium/selenium/dotnet/BUILD.bazel:16:8 PackageZip dotnet/release.zip failed: (Exit 1): compiler_wrapper.bat failed: error executing CSharpCompile command (from target //dotnet/src/webdriver:webdriver) 
    794:  cd /d D:/_bazel/execroot/_main
    795:  SET DOTNET_CLI_HOME=external/rules_dotnet~~dotnet~dotnet_x86_64-pc-windows-msvc
    796:  external\rules_dotnet~\dotnet\private\compiler_wrapper.bat external/rules_dotnet~~dotnet~dotnet_x86_64-pc-windows-msvc/dotnet.exe external/rules_dotnet~~dotnet~dotnet_x86_64-pc-windows-msvc/sdk/7.0.400/Roslyn/bincore/csc.dll @bazel-out/x64_windows-fastbuild-ST-e0f67d5323b6/bin/dotnet/src/webdriver/webdriver/netstandard2.0/ref/WebDriver.dll-0.params
    797:  # Configuration: b5755e686b8da3c127445e15ff2d039eb80cab83ec512e99d1401cc3eec588cd
    798:  # Execution platform: @@local_config_platform//:host
    799:  �[32mINFO: �[0mElapsed time: 356.047s, Critical Path: 81.31s
    800:  �[32mINFO: �[0m1813 processes: 813 internal, 241 local, 759 worker.
    801:  �[31m�[1mERROR: �[0mBuild did NOT complete successfully
    802:  �[0m
    803:  ##[error]Process completed with exit code 1.
    

    ✨ CI feedback usage guide:

    The CI feedback tool (/checks) automatically triggers when a PR has a failed check.
    The tool analyzes the failed checks and provides several feedbacks:

    • Failed stage
    • Failed test name
    • Failure summary
    • Relevant error logs

    In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR:

    /checks "https://github.com/{repo_name}/actions/runs/{run_number}/job/{job_number}"
    

    where {repo_name} is the name of the repository, {run_number} is the run number of the failed check, and {job_number} is the job number of the failed check.

    Configuration options

    • enable_auto_checks_feedback - if set to true, the tool will automatically provide feedback when a check is failed. Default is true.
    • excluded_checks_list - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list.
    • enable_help_text - if set to true, the tool will provide a help message with the feedback. Default is true.
    • persistent_comment - if set to true, the tool will overwrite a previous checks comment with the new feedback. Default is true.
    • final_update_message - if persistent_comment is true and updating a previous checks message, the tool will also create a new message: "Persistent checks updated to latest commit". Default is true.

    See more information about the checks tool in the docs.

    @titusfortner
    Copy link
    Member Author

    @p0deje
    Copy link
    Member

    p0deje commented May 22, 2024

    Figure out a better way to toggle BiDi with Bazel; I foresee us running tests with it toggled on and off, and I'm not sure an environment variable is the right way to do it. (@p0deje probably knows how to allow adding a flag for this)

    We probably want to have both environment variable and a Bazel flag?

    bazel test --bidi rb/...
    bazel test --cdp rb/...
    

    @titusfortner
    Copy link
    Member Author

    @p0deje I'm more thinking about toggling between WebDriver classic and webDriver BiDi commands. I'm not very interested in toggling between CDP & BiDi, because we should be getting away from CDP. 😁

    @p0deje
    Copy link
    Member

    p0deje commented May 22, 2024

    Figure out a better way to toggle BiDi with Bazel; I foresee us running tests with it toggled on and off, and I'm not sure an environment variable is the right way to do it. (@p0deje probably knows how to allow adding a flag for this)

    Maybe then it would be better to have individual test targets for classic and bidi? It would ensure that we properly cache test results and don't re-run unless necessary?

    bazel test //rb/spec/integration/selenium/webdriver:driver-firefox-bidi
    bazel test //rb/spec/integration/selenium/webdriver:driver-firefox-classic
    

    To run all the tests, we'd use:

    bazel test --test_tag_filters bidi rb/spec/...
    bazel test --test_tag_filters classic rb/spec/...
    

    @titusfortner
    Copy link
    Member Author

    @p0deje I think I like that idea more. I created a separate issue to discuss this here - #14020

    @titusfortner titusfortner changed the base branch from trunk to dotnet_async_new May 29, 2024 21:08
    @titusfortner
    Copy link
    Member Author

    I made a mess of this one and can't seem to fix it, closing and opening a new PR. 😁

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    C-devtools BiDi or Chrome DevTools related issues C-dotnet
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    None yet

    2 participants