2016-10-14 5 views
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> 

Я хотел бы отправить кнопку в форме. Сообщение не имеет ни имени, ни 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"); 

Как получить кнопку и отправить форму.

ответ

0

Почему бы не получить данные на основе данных qa?

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