Skip to content

Start the work for the options page #1668

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

Merged
merged 11 commits into from
Apr 17, 2024

Conversation

aguspe
Copy link
Contributor

@aguspe aguspe commented Apr 10, 2024

User description

Description

This PR aims to start improving the example for browser options in the Selenium documentation for the ruby bindings

Currently, most of the examples are lacking and some of the code needs to be moved

Examples:

Screenshot 2024-04-15 at 18 04 05

Motivation and Context

For both newcomers and experienced Selenium users is important to have up-to-date documentation that they can rely on

This update will be split into multiple PRs to not make one big PR and to start updating the documentation right now

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.

Type

enhancement, documentation


Description

  • Added and updated Ruby examples for Chrome driver options, including page load strategies and setting remote capabilities.
  • Updated WebDriver options documentation across multiple languages (English, Japanese, Portuguese, Chinese) with new Ruby examples.
  • Enhanced the upgrade to Selenium 4 documentation with updated Ruby code examples.

Changes walkthrough

Relevant files
Enhancement
options_spec.rb
Enhance Ruby Examples for Browser Options                               

examples/ruby/spec/drivers/options_spec.rb

  • Added examples for Chrome driver options including page load
    strategies and remote capabilities.
  • Introduced a new test case for setting remote capabilities with
    platform name, browser version, and cloud options.
  • +24/-11 
    Documentation
    options.en.md
    Update Ruby Examples in WebDriver Options Documentation   

    website_and_docs/content/documentation/webdriver/drivers/options.en.md

  • Updated Ruby code blocks to reference the new examples in
    options_spec.rb.
  • +3/-3     
    options.ja.md
    Update Japanese WebDriver Options Documentation with Ruby Examples

    website_and_docs/content/documentation/webdriver/drivers/options.ja.md

  • Updated Ruby code blocks to include new examples from options_spec.rb.

  • +3/-3     
    options.pt-br.md
    Enhance Portuguese WebDriver Options Documentation with Ruby Examples

    website_and_docs/content/documentation/webdriver/drivers/options.pt-br.md

  • Added new Ruby examples in the WebDriver options documentation for
    Portuguese readers.
  • +23/-2   
    options.zh-cn.md
    Update Chinese WebDriver Options Documentation with Ruby Examples

    website_and_docs/content/documentation/webdriver/drivers/options.zh-cn.md

  • Included updated Ruby examples in the Chinese WebDriver options
    documentation.
  • +3/-3     
    upgrade_to_selenium_4.en.md
    Update Upgrade to Selenium 4 Documentation with New Ruby Examples

    website_and_docs/content/documentation/webdriver/troubleshooting/upgrade_to_selenium_4.en.md

  • Replaced outdated Ruby code with a reference to the new
    options_spec.rb examples for upgrading to Selenium 4.
  • +1/-8     

    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 Apr 10, 2024

    Deploy Preview for selenium-dev ready!

    Name Link
    🔨 Latest commit 6b1f383
    🔍 Latest deploy log https://app.netlify.com/sites/selenium-dev/deploys/661f4cf8b0ba920008e5424a
    😎 Deploy Preview https://deploy-preview-1668--selenium-dev.netlify.app
    📱 Preview on mobile
    Toggle QR Code...

    QR Code

    Use your smartphone camera to open QR code link.

    To edit notification comments on pull requests, go to your Netlify site configuration.

    aguspe and others added 6 commits April 10, 2024 17:16
    @aguspe aguspe marked this pull request as ready for review April 15, 2024 16:06
    @qodo-merge-pro qodo-merge-pro bot added documentation Improvements or additions to documentation enhancement New feature or request labels Apr 15, 2024
    Copy link
    Contributor

    PR Description updated to latest commit (db98792)

    Copy link
    Contributor

    PR Review

    ⏱️ Estimated effort to review [1-5]

    2, because the changes are focused on adding and updating Ruby examples for Chrome driver options and integrating these examples into the documentation. The modifications are straightforward and well-scoped, making the review process relatively easy.

    🧪 Relevant tests

    Yes

    🔍 Possible issues

    Possible Bug: Ensure that my_test_build and my_test_name variables are defined or passed correctly in the 'sets remote capabilities' test. If these variables are not properly initialized, the test might fail or not work as expected.

    Consistency Check: Verify that the cloud_url variable in the 'sets remote capabilities' test is correctly defined and accessible. This is crucial for the remote WebDriver to connect to the cloud testing service.

    🔒 Security concerns

    No


    ✨ Review tool usage guide:

    Overview:
    The review tool scans the PR code changes, and generates a PR review which includes several types of feedbacks, such as possible PR issues, security threats and relevant test in the PR. More feedbacks can be added by configuring the tool.

    The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.

    • When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:
    /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
    
    [pr_reviewer]
    some_config1=...
    some_config2=...
    

    See the review usage page for a comprehensive guide on using this tool.

    Copy link
    Contributor

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Maintainability
    Refactor repetitive test setup into shared setup blocks.

    Consider wrapping the repetitive setup code for Selenium WebDriver options and driver
    initialization into a shared method or using a before(:each) block to DRY up the tests.
    This will make the tests easier to maintain and read.

    examples/ruby/spec/drivers/options_spec.rb [9-15]

    -options = Selenium::WebDriver::Options.chrome
    -options.page_load_strategy = :normal
    -driver = Selenium::WebDriver.for :chrome, options: options
    -driver.get('https://www.google.com')
    -driver.quit
    +before(:each) do
    +  @options = Selenium::WebDriver::Options.chrome
    +  @driver = Selenium::WebDriver.for :chrome, options: @options
    +end
    +after(:each) { @driver.quit }
     
    Best practice
    Use a constant for the repeated URL to simplify future changes.

    Extract the URL 'https://www.google.com' into a variable or a constant to avoid
    duplication across tests and to make it easier to change the URL in the future if needed.

    examples/ruby/spec/drivers/options_spec.rb [14]

    -driver.get('https://www.google.com')
    +BASE_URL = 'https://www.google.com'
    +driver.get(BASE_URL)
     
    Ensure test names are unique and descriptive.

    For better test isolation and to prevent potential side effects, consider using unique
    test names or descriptions for each test scenario.

    examples/ruby/spec/drivers/options_spec.rb [9]

    -it 'page load strategy normal' do
    +it 'loads page with normal strategy' do
     
    Ensure resources are freed with an ensure block.

    To ensure the resources are always freed even if an error occurs during the test
    execution, use an ensure block to quit the driver.

    examples/ruby/spec/drivers/options_spec.rb [14-15]

    -driver.get('https://www.google.com')
    -driver.quit
    +begin
    +  driver.get('https://www.google.com')
    +ensure
    +  driver.quit
    +end
     
    Security
    Externalize configuration details to environment variables.

    Use environment variables or a configuration file for sensitive or environment-specific
    information like cloud_url, my_test_build, and my_test_name to enhance security and
    flexibility.

    examples/ruby/spec/drivers/options_spec.rb [41-42]

    -cloud_options[:build] = my_test_build
    -cloud_options[:name] = my_test_name
    +cloud_options[:build] = ENV['TEST_BUILD']
    +cloud_options[:name] = ENV['TEST_NAME']
     

    ✨ Improve tool usage guide:

    Overview:
    The improve tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on a PR.

    • When commenting, to edit configurations related to the improve tool (pr_code_suggestions section), use the following template:
    /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
    
    [pr_code_suggestions]
    some_config1=...
    some_config2=...
    

    See the improve usage page for a comprehensive guide on using this tool.

    @aguspe
    Copy link
    Contributor Author

    aguspe commented Apr 15, 2024

    @diemol my Portuguese is not great but I noticed that the Portuguese translation was the only one that was lacking the browserName examples

    Also, I wanted to update all the ruby examples but I did not wanted to give you or others reviewers too much work in one single PR

    @diemol
    Copy link
    Member

    diemol commented Apr 15, 2024

    @diemol my Portuguese is not great but I noticed that the Portuguese translation was the only one that was lacking the browserName examples

    Also, I wanted to update all the ruby examples but I did not wanted to give you or others reviewers too much work in one single PR

    Yes, this was probably overlooked. Feel free to change that, please. Thanks!

    @aguspe
    Copy link
    Contributor Author

    aguspe commented Apr 15, 2024

    @diemol my Portuguese is not great but I noticed that the Portuguese translation was the only one that was lacking the browserName examples

    Also, I wanted to update all the ruby examples but I did not wanted to give you or others reviewers too much work in one single PR

    Yes, this was probably overlooked. Feel free to change that, please. Thanks!

    That's already changed 😊 thank you for the quick response!

    @diemol
    Copy link
    Member

    diemol commented Apr 16, 2024

    @diemol my Portuguese is not great but I noticed that the Portuguese translation was the only one that was lacking the browserName examples

    Also, I wanted to update all the ruby examples but I did not wanted to give you or others reviewers too much work in one single PR

    Yes, this was probably overlooked. Feel free to change that, please. Thanks!

    That's already changed 😊 thank you for the quick response!

    I don't see the changes. And there is an open conversation that needs to be resolved. Thank you!

    @luisfcorreia
    Copy link
    Contributor

    Just a comment, were you suggesting translating code examples to PT or the surrounding text?

    (I got confused)

    @aguspe
    Copy link
    Contributor Author

    aguspe commented Apr 16, 2024

    Just a comment, were you suggesting translating code examples to PT or the surrounding text?

    (I got confused)

    Hi Luis, I noticed that the code examples for browser name were missing in the Portuguese translations as it is now

    Screenshot 2024-04-16 at 16 57 08

    Compared to the English version:

    Screenshot 2024-04-16 at 16 57 26

    So I was wondering if it was on purpose or if the examples were missing :)

    Docs URL: https://www.selenium.dev/documentation/webdriver/drivers/options/

    @aguspe
    Copy link
    Contributor Author

    aguspe commented Apr 16, 2024

    Perfect I will address it tonight, thank you!

    aguspe and others added 3 commits April 17, 2024 06:08
    …s' into add_browser_options_ruby_examples
    @aguspe
    Copy link
    Contributor Author

    aguspe commented Apr 17, 2024

    @diemol Regarding your request for changes, you are absolutely right, the test will not execute

    So I implemented an alternative solution, I added the option to skip the test automatically in rspec during execution with an explanation why, in that way we can move the code, and reference it in multiple places without executing the actual test

    Let me know if you like this solution, if not I will move the code back where it was

    Copy link
    Member

    @diemol diemol left a comment

    Choose a reason for hiding this comment

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

    That works, thank you!

    @diemol diemol merged commit 9a54ed5 into SeleniumHQ:trunk Apr 17, 2024
    9 checks passed
    selenium-ci added a commit that referenced this pull request Apr 17, 2024
    * Start the work for the options page
    
    * Move upgrade to selenium examples
    
    * Update platform name
    
    * Update platform name and platform version
    
    * Add skip method
    
    ---------
    
    Co-authored-by: aguspe <[email protected]>
    
    [deploy site] 9a54ed5
    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.

    None yet

    3 participants