Skip to content

added code for frames ruby #2229

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

Closed

Conversation

pallavigitwork
Copy link
Member

@pallavigitwork pallavigitwork commented Mar 20, 2025

User description

Thanks for contributing to the Selenium site and documentation!
A PR well described will help maintainers to review and merge it quickly

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, and help reviewers by making them as simple and short as possible.

Description

added code for frames ruby

Motivation and Context

added code for frames ruby

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 a comprehensive Ruby test for iframe interactions.

  • Updated Ruby code examples in multiple documentation files.

  • Improved iframe handling documentation across various languages.

  • Adjusted Hugo configuration to ignore specific errors.


Changes walkthrough 📝

Relevant files
Tests
frames_spec.rb
Add Ruby test for iframe interactions                                       

examples/ruby/spec/interactions/frames_spec.rb

  • Added a new test for iframe interactions in Ruby.
  • Demonstrated switching to iframes using WebElement, name, and index.
  • Included interactions with elements inside iframes and returning to
    default content.
  • Added browser setup, navigation, and teardown logic.
  • +40/-2   
    Documentation
    frames.en.md
    Update English iframe documentation with Ruby test links 

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

  • Replaced inline Ruby iframe examples with links to the new Ruby test
    file.
  • Updated documentation to reflect the new Ruby test structure.
  • Removed outdated Ruby iframe examples.
  • +22/-31 
    frames.ja.md
    Update Japanese iframe documentation with Ruby test links

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

  • Replaced inline Ruby iframe examples with links to the new Ruby test
    file.
  • Updated Japanese documentation to reflect the new Ruby test structure.
  • Removed outdated Ruby iframe examples.
  • +28/-20 
    frames.pt-br.md
    Update Portuguese iframe documentation with Ruby test links

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

  • Replaced inline Ruby iframe examples with links to the new Ruby test
    file.
  • Updated Portuguese documentation to reflect the new Ruby test
    structure.
  • Removed outdated Ruby iframe examples.
  • +21/-37 
    frames.zh-cn.md
    Update Chinese iframe documentation with Ruby test links 

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

  • Replaced inline Ruby iframe examples with links to the new Ruby test
    file.
  • Updated Chinese documentation to reflect the new Ruby test structure.
  • Removed outdated Ruby iframe examples.
  • +20/-41 
    Configuration changes
    hugo.toml
    Update Hugo configuration to ignore errors                             

    website_and_docs/hugo.toml

    • Adjusted Hugo configuration to ignore specific errors.
    +1/-1     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link

    netlify bot commented Mar 20, 2025

    👷 Deploy request for selenium-dev pending review.

    Visit the deploys page to approve it

    Name Link
    🔨 Latest commit 8e23555

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Incorrect Frame Selection

    The code uses the same iframe variable twice when switching to a frame by name. Line 26 should be using the frame name directly rather than reusing the iframe WebElement.

    driver.find_element(name: 'iframe1-name')
    driver.switch_to.frame(iframe)
    Missing Assertions

    The test performs actions on elements inside iframes but doesn't verify the results of these actions. Consider adding assertions after sending keys to email fields.

    email_element = driver.find_element(id: 'email')
    email_element.send_keys('admin@selenium.dev')
    email_element.clear

    Copy link
    Contributor

    qodo-merge-pro bot commented Mar 20, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Fix iframe switching by name

    The code attempts to find an element by name but doesn't use the result.
    Instead, it reuses the previously defined iframe variable. You should either
    store the result of find_element in a variable and use it, or directly use the
    name in the switch_to.frame method.

    examples/ruby/spec/interactions/frames_spec.rb [24-26]

     # Switch to iframe using name
    -driver.find_element(name: 'iframe1-name')
    -driver.switch_to.frame(iframe)
    +driver.switch_to.frame('iframe1-name')
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    __

    Why: The current code finds an element by name but doesn't use it, then incorrectly reuses the previous iframe variable. This is a significant bug that would cause the test to not work as intended when switching frames by name.

    High
    General
    Ensure browser cleanup

    The test doesn't handle browser cleanup if an exception occurs during the test.
    Use an ensure block or RSpec's after hook to guarantee the browser is always
    closed, even if the test fails.

    examples/ruby/spec/interactions/frames_spec.rb [42-43]

    -# Quit the browser
    -driver.quit
    +begin
    +  # Test code here
    +ensure
    +  # Quit the browser
    +  driver.quit
    +end
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    __

    Why: The suggestion improves test reliability by ensuring the browser is always closed, even if an exception occurs during test execution. This prevents resource leaks and orphaned browser processes.

    Medium
    • Update

    @pallavigitwork
    Copy link
    Member Author

    @aguspe , thanks for helping with the PR. will wait for further information.

    @pallavigitwork
    Copy link
    Member Author

    halting work on this PR, as i didn't had the devtools gem installed. trying again.
    if it works will close this PR.

    @pallavigitwork
    Copy link
    Member Author

    closing this - created another PR- #2236
    after fixing gem file and other env problem

    @pallavigitwork pallavigitwork deleted the frame-ruby-pal branch April 21, 2025 12:10
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant