thoughtbot / capybara-webkit

A Capybara driver for headless WebKit to test JavaScript web apps
https://thoughtbot.com/open-source
MIT License
1.97k stars 428 forks source link

Problem inserting data #999

Closed RamonjsOliveira closed 6 years ago

RamonjsOliveira commented 7 years ago

When entering a phone number, when the part with ifen arrives, the typing cursor returns to the initial field, so that when entering the sequence "123456" the expected would be "123-456", but the result is "123-564". Any suggestion?

twalpole commented 7 years ago

It could be because the keys are sent too fast for the JS on the page to handle, try

phone_element.set('123').send_keys('456') 

or

phone_element.send_keys('123').send_keys('456')

or potentially

phone_element.set('123-456')

and see if that makes a difference for you - It all depends on exactly what the JS on the page is doing for that input element.

RamonjsOliveira commented 7 years ago

@twalpole During the tests I realized that the field is considering the points and ifens during the replace. This happens only on android devices.

RamonjsOliveira commented 7 years ago

@twalpole During insertion of the text, the points are considered, however, they are not substituted, making the character intended for the point to be displayed in the field next to the point, however, the cursor remains one step earlier, making the sequence "456" Displayed "564". Is it possible to ignore the point? As a palliative solution, I increased 1 digit to the size of the field, because without this, the numbers were not even displayed when typed.