Watir-Webdriver - Unable to locate a button with id, name, text, value

烈酒焚心 提交于 2019-12-12 05:57:28

问题


I am very new to web automation and watir-webdriver. i am trying a script to launch a web and submit the login form. I was able to identify the username and password text fields with the 'id' tag. but the login button doesn't have any of the id, name, text and value keys. i have tried looking all the sources, they all have atleast any one key to search the button. but as i am not seeing that in my web application, could someone help me how to search the button and click it.

Here's a portion of the HTML from the page where the button is identified

<jl-button-bar class="margin-bottom centered ng-scope">
  <button class="primary full jl-button ng-scope" type="submit" tabindex="0">
    <ng-transclude>
      <span class="ng-scope">Login</span>
    </ng-transclude>
  </button>
</jl-button-bar>

回答1:


It is hard to tell what is unique about the button without seeing the entire page. However, assuming there is only one login button, you can probably do:

browser.button(text: 'Login').click

If the application supports multiple languages, you might not want to use the text. If there is only the login form, you can probably do:

browser.button(type: 'submit').click


来源:https://stackoverflow.com/questions/32279082/watir-webdriver-unable-to-locate-a-button-with-id-name-text-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!