salesforce - Using Ruby Watir, how can I select a checkbox that has a changing ID? -


this html i'm working with:

<div class="pbsubsection">     <table class="detaillist" cellspacing="0" cellpadding="0" border="0">         <tbody>             <tr>                 <td class="labelcol">                     <label for="00ni0000003bw8o">becomes asset</label>                 </td>                 <td class="datacol col02">                     <input id="00ni0000003bw8o" type="checkbox" value="1" tabindex="8" name="00ni0000003bw8o" checked="checked">                 </td> 

i need select checkbox.

i cannot use id because i'm doing across multiple orgs, , id different in every org. there way can select label text or tabindex?

it safer checkbox label text rather tabindex.

solution 1 - :label locator:

if using watir-webdriver, possible locate element directly based on label text - via :label locator. can following:

#exact match of label text: b.checkbox(:label => 'becomes asset').set  #partial match of label text using regex: b.checkbox(:label => /asset/).set 

note assumes 'for' attribute of label matches 'id' attribute of input element.

solution 2 - matching label input:

for solution works in watir-classic (as watir-webdriver), can:

  1. get label element text
  2. get attribute of label element
  3. get associated checkbox id, matches label element's attribute

the following work page clear checkbox:

label = browser.label(:text => 'becomes asset') browser.checkbox(:id => label.for).set 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -