Capybara Unable to find Visible field

Asked

Viewed 752 times

0

When rotating the command rake cucumber i get the following error:

Unable to find visible field "article[text]" that is not disabled (Capybara::ElementNotFound)

But the field is visible

File of Stepdefs.Rb:

Given("Eu abro a pagina {string}") do |string|
    visit '/articles'
    expect(page).to have_current_path('/articles')
    expect(page).to have_content(string)
end

When("Eu crio o artigo {string} com o titulo {string}") do |string, string2|
    click_link 'New article'

    fill_in 'article[text]', :with=> string2

    click_button 'submit'
    expect(page).to have_content(string2)
end

Then("Eu vejo que o artigo com o titulo {string} nao foi salvo, pois o titulo do artigo tem menos de {int} caracteres") do |string, int|
    pending # Write code here that turns the phrase above into concrete actions
end

HTML of the page:

<!DOCTYPE html>
<html>
  <head>
    <title>Blog</title>
    <meta name="csrf-param" content="authenticity_token" />
<meta name="csrf-token" content="dTLPqUV7sBKcQVLEC7llglxP8asnwITQ1QA5xptHlE+sfDBcQjd85659a7Q5Wr6toEpfo/k/PdZEzIpspqcgYg==" />

    <link rel="stylesheet" media="all" href="/assets/articles.self-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css?body=1" data-turbolinks-track="reload" />
<link rel="stylesheet" media="all" href="/assets/comments.self-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css?body=1" data-turbolinks-track="reload" />
<link rel="stylesheet" media="all" href="/assets/welcome.self-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css?body=1" data-turbolinks-track="reload" />
<link rel="stylesheet" media="all" href="/assets/application.self-f0d704deea029cf000697e2c0181ec173a1b474645466ed843eb5ee7bb215794.css?body=1" data-turbolinks-track="reload" />
    <script src="/assets/rails-ujs.self-8944eaf3f9a2615ce7c830a810ed630e296633063af8bb7441d5702fbe3ea597.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/articles.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/action_cable.self-69fddfcddf4fdef9828648f9330d6ce108b93b82b0b8d3affffc59a114853451.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/cable.self-8484513823f404ed0c0f039f75243bfdede7af7919dda65f2e66391252443ce9.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/comments.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/welcome.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" data-turbolinks-track="reload"></script>
<script src="/assets/application.self-eba3cb53a585a0960ade5a8cb94253892706bb20e3f12097a13463b1f12a4528.js?body=1" data-turbolinks-track="reload"></script>
  </head>

  <body>

<h1>New article</h1>

<form action="/articles" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><input type="hidden" name="authenticity_token" value="OgAVazJworw8k92uuCCf8UurnXh/cMRAR299FEYX0dcLxAew0HL0q/oD7MSTQeh3phhWACcspk5Rqohog9ydaA==" />


  <p>
    <label for="article_title">Title</label><br>
    <input type="text" name="article[title]" />
  </p>

  <p>
    <label for="article_text">Text</label><br>
    <textarea name="article[text]">
</textarea>
  </p>

  <p>
    <input type="submit" name="commit" value="Create Article" data-disable-with="Create Article" />
  </p>

</form>

<a href="/articles">Back</a>
  </body>
</html>

I’ve tried to use article_text instead of article[text], but to no avail

1 answer

0

Dude, this is a form? guy:

 <label for="name_stado">stado</label><br>
    <input type="text" name="article[sp]" />
    <input type="text" name="article[rj]" />
    <input type="text" name="article[ms]" />
    <input type="text" name="article[pa]" />

If yes, use:

find('label[for="name_stado"]', visible: false).send_keys('rj')

If it doesn’t work take a look at these methods: https://github.com/Vilariano/Automation_Practice/tree/master/features/page

Abs,

Browser other questions tagged

You are not signed in. Login or sign up in order to post.