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 and update ruby code examples with internet explorer #1748

Merged
merged 14 commits into from
Jun 19, 2024

Conversation

aguspe
Copy link
Contributor

@aguspe aguspe commented Jun 2, 2024

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

  • Change to the site (I have double-checked the Netlify deployment, and my changes look good)
  • Code example added (and I also added the example to all translated languages)
  • Improved translation
  • Added new translation (and I also added a notice to each document missing translation)

Checklist

  • I have read the contributing document.
  • I have used hugo to render the site/docs locally and I am sure it works.

PR Type

Enhancement, Documentation


Description

  • Added comprehensive test cases for various Internet Explorer options in Ruby.
  • Updated documentation to link to the new Ruby test cases for Internet Explorer options.
  • Ensured consistency and accuracy in Ruby code examples across multiple languages (English, Japanese, Portuguese, Chinese).

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

    Copy link

    netlify bot commented Jun 2, 2024

    👷 Deploy request for selenium-dev pending review.

    Visit the deploys page to approve it

    Name Link
    🔨 Latest commit 6257dcc

    Copy link
    Member

    @harsha509 harsha509 left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Thank you @aguspe !

    @aguspe aguspe changed the title Migrate code to examples Migrate and update ruby code examples with internet explorer Jun 3, 2024
    @aguspe aguspe marked this pull request as ready for review June 3, 2024 04:55
    @codiumai-pr-agent-pro codiumai-pr-agent-pro bot added documentation Improvements or additions to documentation enhancement New feature or request Review effort [1-5]: 2 labels Jun 3, 2024
    Copy link
    Contributor

    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

    Copy link
    Contributor

    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]

    +{{< 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]

    +{{< 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]

     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]

     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]

     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]

     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]

     {{< 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]

    -{{< 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]

    +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]

    -{{< 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
    Copy link
    Contributor Author

    aguspe commented Jun 5, 2024

    @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
    Copy link
    Member

    harsha509 commented Jun 5, 2024

    @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
    Copy link
    Contributor Author

    aguspe commented Jun 5, 2024

    @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
    Copy link
    Contributor Author

    aguspe commented Jun 6, 2024

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

    @aguspe
    Copy link
    Contributor Author

    aguspe commented Jun 7, 2024

    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
    Copy link
    Contributor Author

    aguspe commented Jun 16, 2024

    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
    Copy link
    Contributor Author

    aguspe commented Jun 18, 2024

    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
    Copy link
    Contributor Author

    aguspe commented Jun 18, 2024

    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:

    SeleniumHQ/selenium#14152

    @aguspe
    Copy link
    Contributor Author

    aguspe commented Jun 19, 2024

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

    @harsha509 harsha509 merged commit 69a9183 into SeleniumHQ:trunk Jun 19, 2024
    9 checks passed
    selenium-ci added a commit that referenced this pull request Jun 19, 2024
    …deploy site]
    
    * Migrate code to examples
    
    * Finish code migration
    
    * Refactor code migration
    
    * Update examples
    
    * Update silent options
    
    * Update silent options
    
    ---------
    
    Co-authored-by: aguspe <[email protected]>
    Co-authored-by: Sri Harsha <[email protected]> 69a9183
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    documentation Improvements or additions to documentation enhancement New feature or request Review effort [1-5]: 2
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants