简体   繁体   中英

Calling a Select_List with Watir-Webdriver Without an ID/Name

I'm currently having trouble calling a Select_List that does not have a name/ID (as the title states).

The HTML for the Select List is:

<select dojoattachpoint="userSelector" size="15" multiple="">

  <option value="_W2kn2sdAEeSmeMQKjIY8Ug"></option>
  <option value="_gkeqUBUqEeG7h6M2lwbcyg"></option>

</select>

What I need to do is select one option in the select list and then click a button, but I can't select the option if I don't know how to point at the list itself.

Note: This is done in Firefox if it matters.

Because "dojoattachpoint" is not a valid attribute for a Select Element per the html5 spec, you can't use it directly. You can access it with css, though: el = browser.select(css: "[dojoattachpoint='userSelector']") You could also look into making the site's code html5 compliant, since I think dojo supports data tags: 'data-dojoattachpoint' or the like. Then your selector could be: el = browser.select(data_dojoattachpoint: 'userSelector')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM