DEV Community

n350071🇯🇵
n350071🇯🇵

Posted on

2 1

[Capybara] find('input').set will have not done!

🔗 Parent Note

🤔 Situation

I have like this HTML and want to set a value into it.



<div class="bootstrap-dialog-message">
  <input type="text" class="form-control">
</div>


Enter fullscreen mode Exit fullscreen mode

😅 set finishes although it's not completed!

When capybara try to input the email,



find('input').set('loooooooooooooooooong@email.com')


Enter fullscreen mode Exit fullscreen mode

the results were like this. it's kind of random error.



1: loooo
2: loooooooooooooooooong@email.com
3: loooooooooooooooooong@e
.
.


Enter fullscreen mode Exit fullscreen mode

👍 Fix it!

Using Until

There is a method until ~ end. You can try again until the condition will succeed.



until find('input') == 'loooooooooooooooooong@email.com'
  find('input').set('loooooooooooooooooong@email.com')
end


Enter fullscreen mode Exit fullscreen mode

Using 10.times



10.times do
  find('input').set('loooooooooooooooooong@email.com')
  break if find('input') == 'loooooooooooooooooong@email.com'
end


Enter fullscreen mode Exit fullscreen mode

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (1)

Collapse
 
sergioprats1 profile image
Sergio Prats López

In my case I was only able to write four characters and when I used larger strings I was getting the Selenium::WebDriver::Error::ElementNotInteractableError exception.

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay