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
There are several problems with your code:
find_fieldfinds fields not forms. Your first find is wrong but your second is correct. Try:page.find('#productForm_7').find_field("productID").valueinstead. Capybaras general purpose find method uses CSS selectors by default. In the same way you can find the buttonpage.find('#productForm_7').find(".btn_addToCart").valueusing the CSS class of the button.However a more capybaraish style is something like this: