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

Made the send_keys helper work in selenium as well as cuprite #3328

Merged
merged 1 commit into from
Oct 14, 2024

Conversation

iainbeeston
Copy link
Contributor

@iainbeeston iainbeeston commented Oct 10, 2024

Description

A few of the test helpers use the type helper method but in selenium it raises this error:

 NoMethodError:
   undefined method `keyboard' for #<Selenium::WebDriver::Chrome::Driver:0x000000013ebbb950>

I've changed this to do the same thing (type in the focused element) but in a way that should work in every capybara driver.

Fixes # (issue)

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Screenshots & recording

Manual review steps

  1. Tests using add_tag and other helpers that use the keyboard should still pass.

Manual reviewer: please leave a comment with output from the test if that's the case.

Copy link

codeclimate bot commented Oct 10, 2024

Code Climate has analyzed commit 3d5f726 and detected 0 issues on this pull request.

View more on Code Climate.

Copy link
Contributor

@Paul-Bob Paul-Bob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @iainbeeston thank you for looking into this.

It seems that page.send_keys(...) is breaking our tests on cuprite.

Not sure if we can make a method that is 100% compatible with both selenium and cuprite, can you have a look into it?

If it's blocking, an alternative approach would be to override it on your side or to make 2 methods:

def cuprite_type(...)
  page.driver.browser.keyboard.type(...)
end

def selenium_type(...)
  page.send_keys(...)
end

A few of the test helpers use the `type` helper method but in selenium it raises this error:

     NoMethodError:
       undefined method `keyboard' for #<Selenium::WebDriver::Chrome::Driver:0x000000013ebbb950>

I've changed this to check if the `keyboard` property exists and if it does not, try sending keys to the page instead (which works in selenium).
@iainbeeston iainbeeston force-pushed the cross-platform-type-helper branch from 9be468c to 3d5f726 Compare October 14, 2024 13:05
@Paul-Bob
Copy link
Contributor

Thank you for this contribution @iainbeeston

@Paul-Bob Paul-Bob merged commit c0d852d into avo-hq:main Oct 14, 2024
22 checks passed
@Paul-Bob Paul-Bob added Enhancement Not necessarily a feature, but something has improved and removed Refactor labels Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Not necessarily a feature, but something has improved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants