0
  <form name="login" action="security_check" method='POST'>
                <input data-qa="login.username" type="text" class="text-box text-box--fluid" placeholder="Username" autofocus=true name='username'/>
                <input data-qa="login.password" type="password" class="text-box text-box--fluid" placeholder="Password" name='password'/>
                <button data-qa="login.submit" type="submit" class="btn btn--primary btn--large" onclick="submit_onclick(this)">Log In</button>
            </form>

I would like submit the button in the form. The submit doesn't have a name or ID

final HtmlForm form = resultPage.getFirstByXPath("//form[@action='security_check']");
        final HtmlTextInput textField =  form.getInputByName("username");
            final HtmlPasswordInput pwd =  form.getInputByName("password"); 

            textField.setValueAttribute("username");
            pwd.setValueAttribute("password-2016"); 

How to fetch the button and submit the form.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Gan
  • 197
  • 1
  • 4
  • 19

1 Answers1

0

Why not fetch based on the data-qa?

button = form.getFirstByXPath("//button[@data-qa='login.submit']");
button.click();