Skip to content
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

[rb] Fix guard issues for Firefox in Mac #15142

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

aguspe
Copy link
Contributor

@aguspe aguspe commented Jan 23, 2025

Description

This PR updates the firefox guards

Motivation and Context

The purpose of this PR is to fix and understand why the firefox guards are failing only for Mac

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Bug fix


Description

  • Updated browser guard conditions for Firefox and Safari.

  • Restricted tests to Chrome and Edge for specific scenarios.

  • Removed exceptions for Firefox and Safari in scroll-related tests.

  • Improved test stability by refining browser-specific conditions.


Changes walkthrough 📝

Relevant files
Bug fix
action_builder_spec.rb
Adjusted browser-specific guards in WebDriver tests           

rb/spec/integration/selenium/webdriver/action_builder_spec.rb

  • Changed pen stylus test to only run on Chrome and Edge.
  • Updated #scroll_to test to exclude Firefox and Safari.
  • Modified #scroll_from tests to restrict to Chrome and Edge.
  • Removed outdated exception reasons for Firefox and Safari.
  • +5/-9     

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

    Test Coverage

    The PR removes Firefox and Safari from scroll-related tests without providing alternative test coverage for these browsers. Consider adding separate browser-specific tests to ensure functionality.

    describe '#scroll_to', only: {browser: %i[chrome edge]} do
      it 'scrolls to element' do
        driver.navigate.to url_for('scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html')
        iframe = driver.find_element(tag_name: 'iframe')
    
        expect(in_viewport?(iframe)).to be false

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add wait for scroll completion

    Consider adding a sleep or explicit wait after scrolling operations to ensure the
    browser has completed the scroll before checking viewport status.

    rb/spec/integration/selenium/webdriver/action_builder_spec.rb [309]

     driver.action.scroll_to(scroll_origin: scroll_origin).perform
    +wait = Selenium::WebDriver::Wait.new(timeout: 5)
    +wait.until { in_viewport?(iframe) }
     expect(in_viewport?(iframe)).to be true
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Adding an explicit wait after scroll operations is a crucial improvement for test reliability, as it prevents flaky tests by ensuring the scroll animation is complete before assertions.

    8
    Replace sleep with explicit wait

    The hardcoded sleep of 0.5 seconds is unreliable. Replace with an explicit wait that
    checks for the checkbox to be present and in viewport.

    rb/spec/integration/selenium/webdriver/action_builder_spec.rb [338-340]

     driver.switch_to.frame(iframe)
    -sleep 0.5
    -checkbox = driver.find_element(name: 'scroll_checkbox')
    +wait = Selenium::WebDriver::Wait.new(timeout: 5)
    +checkbox = wait.until do
    +  element = driver.find_element(name: 'scroll_checkbox')
    +  element if in_viewport?(element)
    +end
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Replacing hardcoded sleep with explicit wait significantly improves test reliability by waiting for the actual condition to be met rather than an arbitrary time period.

    8

    @aguspe aguspe added the C-rb label Jan 23, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant