SeleniumHQ / seleniumhq.github.io

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

Updates the safari technology preview example for ruby #1771

Closed aguspe closed 4 weeks ago

aguspe commented 4 weeks ago

Description

This PR updates the ruby example for the safari technological preview in all the languages

Motivation and Context

It's important that all the examples are up to date and they clearly reflect the usage of Selenium Webdriver

Types of changes

Checklist


PR Type

Enhancement, Documentation


Description


Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
safari_spec.rb
Add test for Safari Technology Preview in Ruby                     

examples/ruby/spec/browsers/safari_spec.rb
  • Added a test for setting Safari Technology Preview.
  • Verified the browser name is 'Safari Technology Preview'.
  • +6/-0     
    Documentation
    safari.en.md
    Update Ruby example link for Safari Technology Preview     

    website_and_docs/content/documentation/webdriver/browsers/safari.en.md
  • Updated Ruby example to link to the new Safari Technology Preview
    test.
  • +1/-1     
    safari.ja.md
    Update Ruby example link for Safari Technology Preview     

    website_and_docs/content/documentation/webdriver/browsers/safari.ja.md
  • Updated Ruby example to link to the new Safari Technology Preview
    test.
  • +1/-1     
    safari.pt-br.md
    Update Ruby example link for Safari Technology Preview     

    website_and_docs/content/documentation/webdriver/browsers/safari.pt-br.md
  • Updated Ruby example to link to the new Safari Technology Preview
    test.
  • +1/-1     
    safari.zh-cn.md
    Update Ruby example link for Safari Technology Preview     

    website_and_docs/content/documentation/webdriver/browsers/safari.zh-cn.md
  • Updated Ruby example to link to the new Safari Technology Preview
    test.
  • +1/-1     

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

    codiumai-pr-agent-pro[bot] commented 4 weeks ago

    PR Reviewer Guide ๐Ÿ”

    โฑ๏ธ Estimated effort to review [1-5] 2
    ๐Ÿงช Relevant tests Yes
    ๐Ÿ”’ Security concerns No
    โšก Key issues to review None
    codiumai-pr-agent-pro[bot] commented 4 weeks ago

    PR Code Suggestions โœจ

    CategorySuggestion                                                                                                                                    Score
    Best practice
    Add an ensure block to quit the driver and prevent resource leaks ___ **To ensure the local_driver is properly closed after the test, consider adding an ensure
    block to quit the driver. This will help prevent resource leaks.** [examples/ruby/spec/browsers/safari_spec.rb [37-38]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1771/files#diff-bdb8fc856236b527e2aaf2466380587350d356f1a1ba23496b66ab97f7e11189R37-R38) ```diff local_driver = Selenium::WebDriver.for :safari -expect(local_driver.capabilities.browser_name).to eq 'Safari Technology Preview' +begin + expect(local_driver.capabilities.browser_name).to eq 'Safari Technology Preview' +ensure + local_driver.quit +end ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 7 Why: Adding an `ensure` block to quit the driver is a good practice to prevent resource leaks, especially in test environments where many instances might be created and destroyed.
    7
    Possible issue
    Add a check to ensure the technology_preview! method is available before calling it ___ **To make the test more robust, add a check to ensure that technology_preview! method is
    available before calling it. This will prevent potential errors if the method is not
    defined.** [examples/ruby/spec/browsers/safari_spec.rb [36]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1771/files#diff-bdb8fc856236b527e2aaf2466380587350d356f1a1ba23496b66ab97f7e11189R36-R36) ```diff -Selenium::WebDriver::Safari.technology_preview! +if Selenium::WebDriver::Safari.respond_to?(:technology_preview!) + Selenium::WebDriver::Safari.technology_preview! +else + skip 'Safari Technology Preview is not available' +end ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 6 Why: Checking if a method exists before calling it can prevent runtime errors, making the test more robust. However, this is a precautionary measure rather than a correction of an existing error.
    6
    aguspe commented 4 weeks ago

    Thank you @aguspe !

    Thank you as usual @harsha509 !