Skip to content

[rb] Move documentation examples for general interactions and navigation #1837

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 3 commits into from
Aug 5, 2024

Conversation

aguspe
Copy link
Contributor

@aguspe aguspe commented Aug 3, 2024

User description

Description

This PR creates a new browser. spec to add examples to the index page of interactions, and move all the examples out of the docs into their correspondents specs

Motivation and Context

The examples and documentation must be easy to maintain, so migrating static code into examples will help this goal

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

Documentation, Tests


Description

  • Added new RSpec tests for browser interactions, including getting the current title and URL.
  • Added new RSpec tests for navigation interactions, including navigating to a page, back, forward, and refreshing.
  • Updated documentation to include new Ruby examples for getting the title and URL.
  • Updated documentation to include new Ruby examples for navigation interactions.
  • Linked documentation examples to new Ruby spec files for better maintainability.

Changes walkthrough 📝

Relevant files
Tests
2 files
browser_spec.rb
Add RSpec tests for browser interactions                                 

examples/ruby/spec/interactions/browser_spec.rb

  • Added new RSpec tests for browser interactions.
  • Tests include getting the current title and URL.
  • +17/-0   
    navigation_spec.rb
    Add RSpec tests for navigation interactions                           

    examples/ruby/spec/interactions/navigation_spec.rb

  • Added new RSpec tests for navigation interactions.
  • Tests include navigating to a page, back, forward, and refreshing.
  • +28/-3   
    Documentation
    8 files
    _index.en.md
    Update Ruby examples for title and URL interactions           

    website_and_docs/content/documentation/webdriver/interactions/_index.en.md

  • Updated Ruby examples for getting title and URL.
  • Linked to new Ruby spec files.
  • +8/-4     
    _index.ja.md
    Update Ruby examples for title and URL interactions (Japanese)

    website_and_docs/content/documentation/webdriver/interactions/_index.ja.md

  • Updated Ruby examples for getting title and URL.
  • Linked to new Ruby spec files.
  • +6/-2     
    _index.pt-br.md
    Update Ruby examples for title and URL interactions (Portuguese)

    website_and_docs/content/documentation/webdriver/interactions/_index.pt-br.md

  • Updated Ruby examples for getting title and URL.
  • Linked to new Ruby spec files.
  • +6/-2     
    _index.zh-cn.md
    Update Ruby examples for title and URL interactions (Chinese)

    website_and_docs/content/documentation/webdriver/interactions/_index.zh-cn.md

  • Updated Ruby examples for getting title and URL.
  • Linked to new Ruby spec files.
  • +6/-2     
    navigation.en.md
    Update Ruby examples for navigation interactions                 

    website_and_docs/content/documentation/webdriver/interactions/navigation.en.md

  • Updated Ruby examples for navigation interactions.
  • Linked to new Ruby spec files.
  • +12/-6   
    navigation.ja.md
    Update Ruby examples for navigation interactions (Japanese)

    website_and_docs/content/documentation/webdriver/interactions/navigation.ja.md

  • Updated Ruby examples for navigation interactions.
  • Linked to new Ruby spec files.
  • +12/-10 
    navigation.pt-br.md
    Update Ruby examples for navigation interactions (Portuguese)

    website_and_docs/content/documentation/webdriver/interactions/navigation.pt-br.md

  • Updated Ruby examples for navigation interactions.
  • Linked to new Ruby spec files.
  • +12/-10 
    navigation.zh-cn.md
    Update Ruby examples for navigation interactions (Chinese)

    website_and_docs/content/documentation/webdriver/interactions/navigation.zh-cn.md

  • Updated Ruby examples for navigation interactions.
  • Linked to new Ruby spec files.
  • +11/-9   

    💡 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 Aug 3, 2024

    👷 Deploy request for selenium-dev pending review.

    Visit the deploys page to approve it

    Name Link
    🔨 Latest commit 2ec2cb9

    @aguspe aguspe changed the title Add examples for documentation [rb] Move documentation examples for general interactions and navigation Aug 4, 2024
    @aguspe aguspe marked this pull request as ready for review August 4, 2024 11:28
    @qodo-merge-pro qodo-merge-pro bot added documentation Improvements or additions to documentation tests Review effort [1-5]: 2 labels Aug 4, 2024
    Copy link
    Contributor

    qodo-merge-pro bot commented Aug 4, 2024

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ No key issues to review

    Copy link
    Contributor

    qodo-merge-pro bot commented Aug 4, 2024

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Best practice
    Use a variable for the URL to reduce repetition and ease updates

    Use a variable to store the URL 'https://www.selenium.dev/' and reuse it across the
    tests to avoid repetition and ease maintenance.

    examples/ruby/spec/interactions/navigation_spec.rb [7-9]

    -driver.navigate.to 'https://www.selenium.dev/'
    -expect(driver.current_url).to eq 'https://www.selenium.dev/'
    +base_url = 'https://www.selenium.dev/'
    +driver.navigate.to base_url
    +expect(driver.current_url).to eq base_url
     
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Using a variable for the URL reduces repetition and makes the code easier to maintain and update. This is a good practice for improving code readability and maintainability.

    8
    Enhancement
    Add page title checks to navigation tests for better validation

    Add assertions to check the page title in addition to the URL to ensure that the
    navigation is successful and the expected page is loaded.

    examples/ruby/spec/interactions/navigation_spec.rb [7-9]

     driver.navigate.to 'https://www.selenium.dev/'
     expect(driver.current_url).to eq 'https://www.selenium.dev/'
    +expect(driver.title).to eq 'Expected Page Title'
     
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Adding page title checks provides better validation that the correct page has loaded, enhancing the robustness of the tests. However, the expected title should be accurate and meaningful.

    7
    Maintainability
    Improve the formatting of the Ruby code block within the tab structure

    Ensure that the Ruby code block is correctly formatted and enclosed within the tab
    structure for consistency with other language tabs.

    website_and_docs/content/documentation/webdriver/interactions/navigation.pt-br.md [26-28]

     {{< tab header="Ruby" text=true >}}
    -{{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L7-L9" >}}
    +  {{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L7-L9" >}}
     {{< /tab >}}
     
    • Apply this suggestion
    Suggestion importance[1-10]: 5

    Why: The suggestion improves the readability and maintainability of the document by ensuring consistent indentation, but it is a minor formatting change.

    5
    Adjust indentation for consistency and improved readability in the Ruby section

    Ensure consistent indentation within the tab structure for the Ruby example to
    improve the document's structure and readability.

    website_and_docs/content/documentation/webdriver/interactions/_index.en.md [27-28]

     {{< tab header="Ruby" text=true >}}
    -{{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L8" >}}
    +  {{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L8" >}}
     
    • Apply this suggestion
    Suggestion importance[1-10]: 5

    Why: Ensuring consistent indentation enhances the document's structure and readability, but it is a minor improvement.

    5
    Combine navigation and URL check into a single step for clarity

    Combine the navigation and retrieval of the current URL into a single step to
    improve test clarity and reduce redundancy.

    examples/ruby/spec/interactions/navigation_spec.rb [7-9]

    -driver.navigate.to 'https://www.selenium.dev/'
    -expect(driver.current_url).to eq 'https://www.selenium.dev/'
    +expect(driver.navigate.to('https://www.selenium.dev/').current_url).to eq 'https://www.selenium.dev/'
     
    • Apply this suggestion
    Suggestion importance[1-10]: 2

    Why: While combining the navigation and URL check into a single step might reduce redundancy, it can make the test harder to read and debug. The current approach is clearer.

    2
    Readability
    Add a newline for better readability in the Ruby tab section

    Add a newline after the Ruby tab header for better readability and consistency with
    other sections.

    website_and_docs/content/documentation/webdriver/interactions/navigation.en.md [26-27]

     {{< tab header="Ruby" text=true >}}
    +
     {{< gh-codeblock path="examples/ruby/spec/interactions/navigation_spec.rb#L7-L9" >}}
     
    • Apply this suggestion
    Suggestion importance[1-10]: 4

    Why: Adding a newline improves readability slightly, but the impact is minimal and does not address any major issues.

    4
    Formatting
    Improve spacing around the Ruby tab content for consistent formatting

    Add spacing around the Ruby tab content to match the formatting of other language
    tabs, enhancing the overall consistency of the document.

    website_and_docs/content/documentation/webdriver/interactions/_index.zh-cn.md [27-28]

     {{< tab header="Ruby" text=true >}}
    +
     {{< gh-codeblock path="examples/ruby/spec/interactions/browser_spec.rb#L8" >}}
     
    • Apply this suggestion
    Suggestion importance[1-10]: 4

    Why: The suggestion enhances the overall consistency of the document's formatting, but it is a minor change with limited impact.

    4

    @harsha509 harsha509 merged commit 1d9f037 into SeleniumHQ:trunk Aug 5, 2024
    8 of 9 checks passed
    selenium-ci added a commit that referenced this pull request Aug 5, 2024
    …ion (#1837)[deploy site]
    
    * Add examples for documentation
    
    * Move documentation examples 1d9f037
    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 Review effort [1-5]: 2 tests
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants