1
votes

I am using Ruby and Watir, trying to automate a page to click on a submit button after filling out the form.

This is the HTML code for the button.

<div class="btns_wr">
<span class="small_green_btn input" title="Submit">
<span class="link_left"></span>
<span class="link_middle">
<input id="submitEnrollmentCmdButtonId" type="submit" value="SUBMIT"     name="submitEnrollmentCmdButtonId">
</span>
<span class="link_right"></span>
</span>
</div>

I have tried multiple variations of class, text, titles etc but it will click the button if I do not fill thr form fields out but when I do fill the form fields out it does not click the button but errors on the very next step of course because the expected result is false.

I have tried the following:

browser.span(:class => 'link_middle').button(:id => 'submitEnrollmentCmdButtonId').click
browser.span(:class => 'link_middle').button(:title => 'Submit').click

With this, at least I got an error message:

Unable to locate element, using {:tag_name=>"button", :id=>"submitEnrollmentCmdButtonId"}

browser.span(:class => 'link_middle').span(:title => 'Submit').click

Unable to locate element, using {:tag_name=>"span", :title => "Submit"}

I am using Firefox; also this form page is opened after I click a button on a page, and this new browser window opens.

1
"I am using Ruby and Watir" => Then why tag the question java but not ruby and not watir - Richard JP Le Guen
Unless Ruby allows it you can't automate a click event, for obvious reasons. - Rick Calder
If the form is in the newly opened browser, you need to explicitly switch to it before using it. In your examples, is browser the main browser or the newly opened one? - Justin Ko

1 Answers

0
votes

Try this:

button(:id => 'submitEnrollmentCmdButtonId').click