Skip to content

Expand options documentation test and examples for Ruby #1679

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 22 commits into from
Apr 27, 2024

Conversation

aguspe
Copy link
Contributor

@aguspe aguspe commented Apr 19, 2024

User description

Description

This PR adds extra tests for the options in ruby and updates the documentation examples, besides that, it also moves the proxy example from the documentation file

Motivation and Context

For new and experienced user to be able to fully understand all the options offered by Selenium is important to have up-to-date documentation with examples

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, Tests, Documentation


Description

  • Added multiple new tests in Ruby for Selenium WebDriver options including handling untrusted certificates, unhandled prompts, window rect, strict file interactability, and proxy settings.
  • Updated English, Japanese, Brazilian Portuguese, and Chinese WebDriver documentation to link to the new Ruby code examples.

Changes walkthrough

Relevant files
Tests
options_spec.rb
Expand Selenium WebDriver Options Tests in Ruby                   

examples/ruby/spec/drivers/options_spec.rb

  • Added tests for handling untrusted certificates, unhandled prompts,
    window rect, strict file interactability, and proxy settings in Chrome
    and Firefox.
  • +45/-0   
    Documentation
    options.en.md
    Update English WebDriver Options Documentation with Ruby Examples

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

  • Updated Ruby code examples with links to the new tests in the
    options_spec.rb.
  • +5/-10   
    options.ja.md
    Update Japanese WebDriver Options Documentation with Ruby Examples

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

  • Updated Japanese WebDriver documentation to include new Ruby test
    examples.
  • +5/-11   
    options.pt-br.md
    Update Brazilian Portuguese WebDriver Options Documentation with Ruby
    Examples

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

  • Updated Brazilian Portuguese WebDriver documentation to include new
    Ruby test examples.
  • +5/-10   
    options.zh-cn.md
    Update Chinese WebDriver Options Documentation with Ruby Examples

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

  • Updated Chinese WebDriver documentation to include new Ruby test
    examples.
  • +5/-11   

    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 19, 2024

    👷 Deploy request for selenium-dev pending review.

    Visit the deploys page to approve it

    Name Link
    🔨 Latest commit e49c40d

    @qodo-merge-pro qodo-merge-pro bot added documentation Improvements or additions to documentation enhancement New feature or request tests labels Apr 19, 2024
    Copy link
    Contributor

    PR Description updated to latest commit (49af31b)

    Copy link
    Contributor

    PR Review

    ⏱️ Estimated effort to review [1-5]

    2, because the PR involves adding new test cases and updating documentation which are generally straightforward to review. The changes are localized and do not involve complex logic changes.

    🧪 Relevant tests

    Yes

    🔍 Possible issues

    Possible Bug: The test 'sets window rect' uses 'set_window_rect = true' which is not a valid method or property for setting window dimensions in Selenium WebDriver. This should be replaced with the correct method to set window size or position.

    🔒 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.

    @aguspe
    Copy link
    Contributor Author

    aguspe commented Apr 19, 2024

    Hello @diemol one question about the documentation, does it make sense that the timeouts are under the options page and not on its page?

    If it does, I can also update the timeouts example on this PR

    Screenshot 2024-04-19 at 20 40 42

    Copy link
    Contributor

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Bug
    Replace the incorrect method for setting window size with the correct one.

    Instead of setting options.set_window_rect = true directly, it's recommended to use the
    method window_size= to specify the dimensions, as set_window_rect is not a valid method
    for setting window size directly in Selenium WebDriver.

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

    -options.set_window_rect = true
    +options.window_size = [width, height]
     
    Enhancement
    Add error handling for navigation to insecure sites.

    Ensure to handle exceptions or errors when navigating to potentially insecure sites like
    'https://expired.badssl.com/' to avoid unhandled exceptions in cases where the browser
    blocks the navigation.

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

    -driver.get('https://expired.badssl.com/')
    +begin
    +  driver.get('https://expired.badssl.com/')
    +rescue Selenium::WebDriver::Error => e
    +  puts "Navigation failed: #{e.message}"
    +end
     
    Enhance the proxy configuration to handle multiple traffic types.

    Use a more specific proxy configuration, including other necessary proxy settings such as
    SSL and FTP, to ensure all traffic types are correctly routed through the proxy.

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

    -options.proxy = Selenium::WebDriver::Proxy.new(http: 'myproxy.com:8080')
    +options.proxy = Selenium::WebDriver::Proxy.new(http: 'myproxy.com:8080', ssl: 'myproxy.com:8080', ftp: 'myproxy.com:8080')
     
    Best practice
    Make file interactability behavior configurable based on test needs.

    Instead of setting options.strict_file_interactability = true directly, consider the
    implications on user interactions and possibly provide a configuration option to toggle
    this behavior based on the test requirements.

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

    -options.strict_file_interactability = true
    +options.strict_file_interactability = some_condition ? true : false
     
    Maintainability
    Refactor code to use a shared options setup for DRY principle adherence.

    Consolidate the repeated instantiation of Selenium::WebDriver::Options.chrome into a
    shared context or before block to reduce redundancy and improve test maintainability.

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

    -options = Selenium::WebDriver::Options.chrome
    +before(:each) do
    +  @options = Selenium::WebDriver::Options.chrome
    +end
     

    ✨ 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.

    @harsha509
    Copy link
    Member

    Hello @diemol one question about the documentation, does it make sense that the timeouts are under the options page and not on its page?

    If it does, I can also update the timeouts example on this PR

    Screenshot 2024-04-19 at 20 40 42

    Hi @aguspe,

    The timeout mentioned refers to the W3C capability timeout in W3C WebDriver, see https://www.w3.org/TR/webdriver2/#capabilities

    Also, It covers features like ScriptTimeout, PageLoadTimeout, and ImplicitWaitTimeout, as per the WebDriver documentation. see https://www.w3.org/TR/webdriver2/#timeouts

    So, I believe it's correctly included in the driver options section.

    Thanks,
    Sri

    @aguspe
    Copy link
    Contributor Author

    aguspe commented Apr 24, 2024

    Hello @diemol one question about the documentation, does it make sense that the timeouts are under the options page and not on its page?
    If it does, I can also update the timeouts example on this PR
    Screenshot 2024-04-19 at 20 40 42

    Hi @aguspe,

    The timeout mentioned refers to the W3C capability timeout in W3C WebDriver, see https://www.w3.org/TR/webdriver2/#capabilities

    Also, It covers features like ScriptTimeout, PageLoadTimeout, and ImplicitWaitTimeout, as per the WebDriver documentation. see https://www.w3.org/TR/webdriver2/#timeouts

    So, I believe it's correctly included in the driver options section.

    Thanks, Sri

    Thank you so much for the help I have updated this PR to cover the timeout examples :)

    @aguspe
    Copy link
    Contributor Author

    aguspe commented Apr 25, 2024

    Hi @harsha509 before this gets merged I need to update some lines because I added a new let on the Rspec test so I'm missing some updates

    @harsha509
    Copy link
    Member

    HI @aguspe ,

    can you do it in a new PR if possible ? let me know

    Thanks,
    Sri

    @aguspe
    Copy link
    Contributor Author

    aguspe commented Apr 25, 2024

    HI @aguspe ,

    can you do it in a new PR if possible ? let me know

    Thanks, Sri

    I just updated it in a commit here and I fixed a documentation bug, I hope that's okey

    @aguspe
    Copy link
    Contributor Author

    aguspe commented Apr 26, 2024

    Hello @harsha509 would it be possible to merge this PR? I will create a new PR to expand the selenium docs and correct an issue with the upgrade selenium ruby example but I keep merging trunk into this PR because it gets out of sync :)

    Thank you so much

    @aguspe
    Copy link
    Contributor Author

    aguspe commented Apr 26, 2024

    This PR needs to be merged before #1695

    @harsha509
    Copy link
    Member

    Thank you @aguspe !

    @harsha509 harsha509 merged commit 568da88 into SeleniumHQ:trunk Apr 27, 2024
    9 checks passed
    chamiz pushed a commit to chamiz/seleniumhq.github.io that referenced this pull request Apr 29, 2024
    )[deploy site]
    
    * Expand options documentation test and examples
    
    * Update timeouts examples
    
    * Update all navigations
    
    * Update options after updating the tests
    
    * Update options after updating the tests
    
    * Fix documentation bug
    
    ---------
    
    Co-authored-by: aguspe <[email protected]>
    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 tests
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants