SeleniumHQ / seleniumhq.github.io

Official Selenium website and documentation
https://selenium.dev
Apache License 2.0
1.07k stars 1.27k forks source link

Migrate and update ruby code examples with internet explorer #1748

Closed aguspe closed 2 months ago

aguspe commented 3 months ago

User description

Description

This PR migrates and adds code examples using ruby for IE

Motivation and Context

It's important to keep the examples and documentation up to date to facilitate usage by all the users

Types of changes

Checklist


PR Type

Enhancement, Documentation


Description


Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
internet_explorer_spec.rb
Add comprehensive test cases for Internet Explorer options in Ruby.

examples/ruby/spec/browsers/internet_explorer_spec.rb
  • Added multiple test cases for Internet Explorer options.
  • Included tests for file upload dialog timeout, clean session, zoom
    settings, and protected mode settings.
  • Added tests for silent option and command line options.
  • Ensured proper driver quit in each test case.
  • +57/-1   
    Documentation
    internet_explorer.en.md
    Update Ruby code examples in Internet Explorer documentation.

    website_and_docs/content/documentation/webdriver/browsers/internet_explorer.en.md
  • Updated Ruby code examples with links to the new test cases.
  • Ensured consistency in documentation for Ruby examples.
  • +23/-52 
    internet_explorer.ja.md
    Update Ruby code examples in Japanese Internet Explorer documentation.

    website_and_docs/content/documentation/webdriver/browsers/internet_explorer.ja.md
  • Updated Ruby code examples with links to the new test cases.
  • Ensured consistency in documentation for Ruby examples.
  • +24/-53 
    internet_explorer.pt-br.md
    Update Ruby code examples in Portuguese Internet Explorer
    documentation.

    website_and_docs/content/documentation/webdriver/browsers/internet_explorer.pt-br.md
  • Updated Ruby code examples with links to the new test cases.
  • Ensured consistency in documentation for Ruby examples.
  • +24/-55 
    internet_explorer.zh-cn.md
    Update Ruby code examples in Chinese Internet Explorer documentation.

    website_and_docs/content/documentation/webdriver/browsers/internet_explorer.zh-cn.md
  • Updated Ruby code examples with links to the new test cases.
  • Ensured consistency in documentation for Ruby examples.
  • +24/-53 

    ๐Ÿ’ก PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    netlify[bot] commented 3 months ago

    Deploy request for selenium-dev pending review.

    Visit the deploys page to approve it

    Name Link
    Latest commit 6257dccbd2865a88739076c1f4e59c76da0a4e9d
    codiumai-pr-agent-pro[bot] commented 3 months ago

    PR Review ๐Ÿ”

    โฑ๏ธ Estimated effort to review [1-5] 2, because the PR primarily involves updates to test cases and documentation for Internet Explorer in Ruby. The changes are straightforward and well-documented, making the review process less time-consuming.
    ๐Ÿงช Relevant tests Yes
    โšก Possible issues No
    ๐Ÿ”’ Security concerns No
    codiumai-pr-agent-pro[bot] commented 3 months ago

    PR Code Suggestions โœจ

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Verify that the gh-codeblock paths correctly reference the intended lines in the Ruby example file ___ **Ensure that the gh-codeblock paths are correct and point to the intended lines in the Ruby
    example file. Verify that the lines referenced in the paths
    /examples/ruby/spec/browsers/internet_explorer_spec.rb#L22-L24,
    /examples/ruby/spec/browsers/internet_explorer_spec.rb#L29-L31, etc., contain the correct
    code snippets.** [website_and_docs/content/documentation/webdriver/browsers/internet_explorer.pt-br.md [118]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1748/files#diff-fe2d01308c167a177a9d3bbb5ab5d10e71e644ca3fe386c5936fd9de12346b03R118-R118) ```diff +{{< gh-codeblock path="/examples/ruby/spec/browsers/internet_explorer_spec.rb#L22-L24" >}} - ```
    Suggestion importance[1-10]: 7 Why: The suggestion to verify the correctness of `gh-codeblock` paths is relevant and important for ensuring that the documentation links to the appropriate code snippets. This helps maintain the accuracy and usefulness of the documentation.
    7
    Verify the correctness of gh-codeblock paths to ensure they point to the correct lines in the Ruby example file ___ **Ensure that the gh-codeblock paths are correct and point to the intended lines in the Ruby
    example file. Incorrect paths can lead to broken links or incorrect code snippets being
    displayed.** [website_and_docs/content/documentation/webdriver/browsers/internet_explorer.zh-cn.md [114]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1748/files#diff-492f3c9f55f8b46ec55057baee400031d06cc5744d6d630ea1f160d849e65d86R114-R114) ```diff +{{< gh-codeblock path="/examples/ruby/spec/browsers/internet_explorer_spec.rb#L22-L24" >}} - ```
    Suggestion importance[1-10]: 7 Why: Ensuring the correctness of `gh-codeblock` paths is important to avoid broken links and incorrect code snippets, which directly impacts user experience and documentation accuracy.
    7
    Best practice
    Use a begin...ensure block to ensure WebDriver cleanup in the file upload dialog timeout test ___ **To ensure that the WebDriver instance is properly cleaned up even if an exception occurs,
    use a begin...ensure block for the file upload dialog timeout test.** [examples/ruby/spec/browsers/internet_explorer_spec.rb [22-25]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1748/files#diff-0ae188a376b0174e0ca12b28866fe852ecec6711f257216da452ed61630ef3bfR22-R25) ```diff options = Selenium::WebDriver::IE::Options.new options.file_upload_dialog_timeout = 2000 driver = Selenium::WebDriver.for(:ie, options: options) -driver.quit +begin + # Test code here +ensure + driver.quit +end ```
    Suggestion importance[1-10]: 7 Why: The suggestion correctly identifies a best practice for ensuring resources are cleaned up properly using `begin...ensure` in Ruby, which is crucial for preventing resource leaks during exceptions.
    7
    Use a begin...ensure block to ensure WebDriver cleanup in the clean session test ___ **To ensure that the WebDriver instance is properly cleaned up even if an exception occurs,
    use a begin...ensure block for the clean session test.** [examples/ruby/spec/browsers/internet_explorer_spec.rb [29-32]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1748/files#diff-0ae188a376b0174e0ca12b28866fe852ecec6711f257216da452ed61630ef3bfR29-R32) ```diff options = Selenium::WebDriver::IE::Options.new options.ensure_clean_session = true driver = Selenium::WebDriver.for(:ie, options: options) -driver.quit +begin + # Test code here +ensure + driver.quit +end ```
    Suggestion importance[1-10]: 7 Why: This suggestion is valid as it promotes the use of `begin...ensure` for resource cleanup, which is important for maintaining stable test environments and handling exceptions gracefully.
    7
    Use a begin...ensure block to ensure WebDriver cleanup in the ignore zoom setting test ___ **To ensure that the WebDriver instance is properly cleaned up even if an exception occurs,
    use a begin...ensure block for the ignore zoom setting test.** [examples/ruby/spec/browsers/internet_explorer_spec.rb [36-39]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1748/files#diff-0ae188a376b0174e0ca12b28866fe852ecec6711f257216da452ed61630ef3bfR36-R39) ```diff options = Selenium::WebDriver::IE::Options.new options.ignore_zoom_level = true driver = Selenium::WebDriver.for(:ie, options: options) -driver.quit +begin + # Test code here +ensure + driver.quit +end ```
    Suggestion importance[1-10]: 7 Why: Applying a `begin...ensure` block for cleanup in test cases is a good practice to ensure that resources are always freed even if the test fails, which is correctly suggested here.
    7
    Use a begin...ensure block to ensure WebDriver cleanup in the ignore protected mode settings test ___ **To ensure that the WebDriver instance is properly cleaned up even if an exception occurs,
    use a begin...ensure block for the ignore protected mode settings test.** [examples/ruby/spec/browsers/internet_explorer_spec.rb [43-46]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1748/files#diff-0ae188a376b0174e0ca12b28866fe852ecec6711f257216da452ed61630ef3bfR43-R46) ```diff options = Selenium::WebDriver::IE::Options.new options.ignore_protected_mode_settings = true driver = Selenium::WebDriver.for(:ie, options: options) -driver.quit +begin + # Test code here +ensure + driver.quit +end ```
    Suggestion importance[1-10]: 7 Why: The suggestion to use `begin...ensure` for managing WebDriver instances is appropriate and enhances the robustness of the test by ensuring proper cleanup, which is especially important in configuration-sensitive tests like this one.
    7
    Add a note about version compatibility for the Ruby code examples ___ **Consider adding a note or warning if the Ruby code examples require specific versions of
    the Selenium WebDriver or Internet Explorer driver. This can help users avoid
    compatibility issues.** [website_and_docs/content/documentation/webdriver/browsers/internet_explorer.en.md [117]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1748/files#diff-b887e55fa380db36be93803cc07213e0bfc1b22d72bd64e9716799c59f9970ecR117-R117) ```diff {{< gh-codeblock path="/examples/ruby/spec/browsers/internet_explorer_spec.rb#L22-L24" >}} +{{< note >}} Ensure you are using a compatible version of Selenium WebDriver and Internet Explorer driver. {{< /note >}} ```
    Suggestion importance[1-10]: 6 Why: Including version compatibility notes is crucial for preventing user confusion and compatibility issues, which enhances the documentation's utility and prevents potential errors during implementation.
    6
    Ensure consistent formatting of tab headers across different languages ___ **Ensure consistency in the formatting of the tab headers across different languages. For
    example, some headers have text=true while others do not. Consistent formatting improves
    readability and maintainability.** [website_and_docs/content/documentation/webdriver/browsers/internet_explorer.zh-cn.md [113]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1748/files#diff-492f3c9f55f8b46ec55057baee400031d06cc5744d6d630ea1f160d849e65d86R113-R113) ```diff -{{< tab header="Ruby" text=true >}} +{{< tab header="Ruby" >}} ```
    Suggestion importance[1-10]: 5 Why: Consistency in formatting, such as the use of `text=true` across similar elements, is a good practice for maintainability and readability, though it's a relatively minor issue.
    5
    Enhancement
    Add context or description around the gh-codeblock to explain the purpose of the Ruby code snippet ___ **Add a brief description or context around the gh-codeblock to explain what the Ruby code
    snippet is demonstrating. This will help users understand the purpose of the code snippet
    without needing to refer to the external file.** [website_and_docs/content/documentation/webdriver/browsers/internet_explorer.pt-br.md [118]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1748/files#diff-fe2d01308c167a177a9d3bbb5ab5d10e71e644ca3fe386c5936fd9de12346b03R118-R118) ```diff +This snippet demonstrates setting the file upload dialog timeout in Ruby: {{< gh-codeblock path="/examples/ruby/spec/browsers/internet_explorer_spec.rb#L22-L24" >}} ```
    Suggestion importance[1-10]: 6 Why: Adding descriptive context around code snippets enhances documentation readability and user understanding, making this a valuable suggestion. However, it's a relatively minor enhancement compared to functional code changes.
    6
    Add context or description around gh-codeblock to explain the purpose of the code snippet ___ **Add a brief description or context around the gh-codeblock to explain what the code
    snippet demonstrates. This will help users understand the purpose of the code snippet
    without having to look at the external file.** [website_and_docs/content/documentation/webdriver/browsers/internet_explorer.en.md [117]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1748/files#diff-b887e55fa380db36be93803cc07213e0bfc1b22d72bd64e9716799c59f9970ecR117-R117) ```diff -{{< gh-codeblock path="/examples/ruby/spec/browsers/internet_explorer_spec.rb#L22-L24" >}} +{{< gh-codeblock path="/examples/ruby/spec/browsers/internet_explorer_spec.rb#L22-L24" >}} +This snippet demonstrates setting the file upload dialog timeout for Internet Explorer in Ruby. ```
    Suggestion importance[1-10]: 6 Why: Adding context to code snippets helps users understand their purpose without needing to reference external files, improving the documentation's self-sufficiency and clarity.
    6
    aguspe commented 2 months ago

    @harsha509 I saw some window tests failing should I skip the IE examples I added? It's a bit difficult for me locally to test IE due to my computer being a mac

    harsha509 commented 2 months ago

    @harsha509 I saw some window tests failing should I skip the IE examples I added? It's a bit difficult for me locally to test IE due to my computer being a mac

    we need to execute tests in chromium edge (IE in edge mode), can you try setting this option attach_to_edge_chrome: true

    aguspe commented 2 months ago

    @harsha509 I saw some window tests failing should I skip the IE examples I added? It's a bit difficult for me locally to test IE due to my computer being a mac

    we need to execute tests in chromium edge (IE in edge mode), can you try setting this option attach_to_edge_chrome: true

    Perfect, I will do it tomorrow and update the whole PR

    aguspe commented 2 months ago

    @harsha509 the whole PR is updated, I hope that does the trick :)

    aguspe commented 2 months ago

    I can see that the following 2 tests are failing on windows:

    1) Internet Explorer Options adds the silent option Failure/Error: Selenium::WebDriver.for(:ie, options: @options)

     Selenium::WebDriver::Error::WebDriverError:
       These options are not w3c compliant: {"silent"=>{:silent=>true}}
     ./spec/browsers/internet_explorer_spec.rb:54:in `block (3 levels) in <top (required)>'

    2) Internet Explorer Options launches ie with the create process api Failure/Error: Selenium::WebDriver.for(:ie, options: @options)

     Selenium::WebDriver::Error::SessionNotCreatedError:
       Unexpected error launching Internet Explorer. Unable to use CreateProcess() API. To use CreateProcess() with Internet Explorer 8 or higher, the value of registry setting in HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0'.
     ./spec/browsers/internet_explorer_spec.rb:65:in `block (3 levels) in <top (required)>'
    
     I will try to set up parallels and see if I can reproduce them on my mac
    aguspe commented 2 months ago

    Hi @harsha509 I hope you are doing well, I updated the 2 tests that were failing and hopefully the pipeline will be green this time

    aguspe commented 2 months ago

    Hi @harsha509 I re-merged the trunk, so I hope the tests are ready to run again, after this I will continue updating the ruby docs, thank you so much!

    aguspe commented 2 months ago

    Hi @harsha509 I looked more into it and I found that the ruby library does not support the silent option so I added it on this PR as it is on other bindings such as java and js, once the PR is merged, the test will stop failing:

    https://github.com/SeleniumHQ/selenium/pull/14152

    aguspe commented 2 months ago

    The PR adding support for the silent capability has been merged https://github.com/SeleniumHQ/selenium/pull/14152, so for now I will skip the silent test until the release of selenium 4.22.0, so everything should work now @harsha509