Capybara::ElementNotFound when element is clearly on page

I am currently trying to fix a Capybara error that came out of no where. It is causing all of my test to fail. These test use to work and I am not sure what has changed as the error doesn't make much sense

The Error

Unable to find visible field "Username" that is not disabled (Capybara::ElementNotFound)

The HTML I get from puts on page.body and save_and_open_page

<div class="login-field">
   <span><i class="fa fa-user fa-lg"></i></span>
   <span><input autofocus="autofocus" placeholder="Username" type="text" name="user[username]" id="user_username"></span>
<div class="login-field">
   <password-entry the-id="user_password" name="user[password]" placeholder="Password" show-lock="true"></password-entry>

The test itself

fill_in "Username", with: "username"
fill_in 'Password', with: "password"
click_button "Login"

I have tried to do finds and also look ups by id. I think the error must be deeper then it not finding the element because it clearly is rendering the element

1 answer

  • answered 2018-07-11 10:58 Kiran Reddy

    Try to debug and add "byebug" before the line its failing. see the console for more error details

    Also, try to find it first and add an attribute "visible: true"