Input() with Key.ENTER and click() don't work as expected
See original GitHub issueI’m using the standalone version. To run this code use 0.9.6-RC3
because of this reported bug.
I have two questions highlighted below, as comments in the code.
Feature: Amazon UI automation
Background:
* def baseUrl = 'https://www.amazon.com/'
Scenario: Search for item
Given driver baseUrl
And def searchTerm = "Explore It"
And def searchTermEncoded = "Explore+It"
# Q1: Key.ENTER should trigger the search but nothing happens, like the key isn't sent. Why?
# When input("#twotabsearchtextbox", [searchTerm, Key.ENTER])
# So I have to click the search button manually
When input("#twotabsearchtextbox", searchTerm)
And click("#nav-search-submit-text")
# Q2: At this moment, I should be seeing the search results, but I'm still in the homepage. Why?
Then match driver.url contains "s?k=" + searchTermEncoded
And locate("div.s-result-list").exists
And locate("{span}Reduce Risk and Increase Confidence").exists
I tried using the same actions and selectors on Cypress and the flow works. Am I doing something wrong in Karate? Why can’t I reach the search results page?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Pressing Enter key on input field does not work as expected
For some reason when I press the Enter key while on the input field it doesn't submit the form. Instead the focus is...
Read more >Input() with Key.ENTER and click() don't work as expected
I'm using the standalone version. To run this code use 0.9.6-RC3 because of this reported bug. I have two questions highlighted below, ...
Read more >The Enter Key should Submit Forms, Stop Suppressing it
When enter is clicked in the number input, the keypress event handler determines which submit button is appropriate and clicks it. While this ......
Read more >On Change action - waiting for the enter key - OutSystems
Edward I have used the Run Javascript in the on change action and it does not work. Eduardo is right. But the problem...
Read more >When a Click is Not Just a Click | CSS-Tricks
The click event is usually tied to a pointer device, typically the mouse, and yet here the Space or Enter key are triggering...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
for those coming across this thread in the future - after more investigation - the ENTER key was indeed being handled wrong in chrome native, which is now fixed in #1192
haha, I have an open mind 😉 Cypress had its problems too in the first years
Here’s what I tried:
Then waitForUrl('s?k=' + searchTermEncoded)
And mouse("#nav-search-submit-text").click()
So thatThis alone is not enough to fix the testclick()
andmouse().click()
are diff syntaxes for the same behaviourAnd waitFor('#nav-search-submit-text').click()
after the mouse click. This worked… 🎉 sometimes 😢My results:
mouse().click()
together withwaitFor().click()
. Please tell me I don’t have to wait for every UI interaction 😱Explore It
” just “Explore
” or “Explore I
”.mouse().click()
step doesn’t wait for the previous step to finish. Karate should run all steps of a given test sequentially right? Or are they executed in parallel? (Selenium runs steps sequentially. Cypress runs commands in parallel, but still, each step executes after the previous)waitFor().click()
is not reliable either. One time the click and page reload was so fast, that when thewaitFor
executed, the page had reloaded and the button was no longer there:TypeError: Cannot read property 'click' of null
For reference, this is the test code that sometimes works: