user1489080
user1489080

Reputation: 11

Cannot click submit button if form information is inputted

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.

Upvotes: 1

Views: 557

Answers (1)

Željko Filipin
Željko Filipin

Reputation: 57262

Try this:

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

Upvotes: 0

Related Questions