I have faced an issue while using .set(#{value})
to fill the text field in registering form, e.g: the phone number i wanna put in is 506307
then it ended up with 063075
.
The work-around i have been made is executing Javascript block like
execute_script("document.querySelector('#{selector}').value = '#{value}'")
However, using the same scripts applying for Webmobile based on React.JS, the scripts above just send the text but didn't send the onChange
event, which cause another element cannot be selected/clicked -> made the test failed.
I came up with another approach is to use the send_keys #{value}
to trigger the key-pressed event that would make browser think there was a key-pressed event happen for that form, but it ended up with race-condition like set(#{value})
as i mentioned.
The another work-around is using What is the best way to trigger onchange event in react js , but i tend to use the native Capybara actions before making that tricky Javascript.
So, is there any other way to interact / fill the form field which won't cause that Race condition issue ?
Thanks everybody in advance.