Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8905019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:17:08+00:00 2026-06-15T02:17:08+00:00

Let’s say if I have multiples of the following code(each with different form name,

  • 0

Let’s say if I have multiples of the following code(each with different form name, productForm_1, .._2…_3 etc):

<form id="productForm_7" name="productForm_3" method="post" action="/send/coded.cfm" style="width:110px; display:inline;">    
<div>
    <input type="hidden" value="24775643" name="productID">
    <input class="btn_addToCart" type="submit" value=" " style="cursor:pointer;">
</div>
</form>

How would I go around changing the productID in capybara-webkit?
And since the button doesn’t have a name/value, how do I specify the button?

I tried

page.find_field('productForm_7').find_field("productID").value

but that doesn’t seem to work at all.

*sorry, I’m new to capybara/nokogiri

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:17:09+00:00Added an answer on June 15, 2026 at 2:17 am

    There are several problems with your code:

    • as shioyama pointed out you shouldn’t change the value of a hidden field. If it really changes on the page – quite possible if the page has some scripts – you should try to trigger the change in the same way from your test.
    • find_field finds fields not forms. Your first find is wrong but your second is correct. Try: page.find('#productForm_7').find_field("productID").value instead. Capybaras general purpose find method uses CSS selectors by default. In the same way you can find the button page.find('#productForm_7').find(".btn_addToCart").value using the CSS class of the button.

    However a more capybaraish style is something like this:

    within '#productForm_7' do
      # fill in values.... for example fill_in '#productID', :with => '123456'
      find('.btn_addToCart').click
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have the following piece of code. To test this, I change
Let's say I have the following object: var VariableName = { firstProperty: 1, secondProperty:
Let's say I have this code: <p dataname=description> Hello this is a description. <a
let's say I have the following string: string s = A B C D
Let's say I have the following entity: public class Store { public List<Product> Products
let's say I have a select list as follows: <select name='languages'> <option value='german'>German</option> <option
Let's say I have the following classes : public class MyProductCode { private String
Let's say I have window.open (without name parameter), scattered in my project and I
Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
Let's say I have a domain object with the following field: private Map<StatType, Double>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.