Selenium webdriver CSS attribute reading

I have the below kind HTML :

<input type="submit" name="btnAddRequest" value="Add Bizz1"
onclick="validSubmit=true;document.forms[0].elements['fieldViewerId'].value
= 12676701;" class="btnSmall">
<input type="submit" name="btnAddRequest" value="Update Bizz1"
onclick="validSubmit=true;document.forms[0].elements['fieldViewerId'].value
= 12676701;" class="btnSmall">
<input type="submit" name="btnAddRequest" value="Add Bizz2"
onclick="validSubmit=true;document.forms[0].elements['fieldViewerId'].value
= 12676701;" class="btnSmall">

I am using selenium-webdriver.

driver.find_elements(:name,"btnAddRequest")

- giving all the three of the above. But I want to `click` only one the
one having value as `Update Bizz1` . How to perform such test any idea?
There are 100 buttons like this. I just pasted three of them.

···

--
Posted via http://www.ruby-forum.com/.

I don't think selenium webdriver allows for selection on multiple
criteria the way watir webdriver does.
You'd probably have to do something like this:

driver.find_elements(:name,"btnAddRequest").select {|el| el.name ==
"btnAddRequest" }.first.click

It seems unnecessarily long-winded to me. Watir-webdriver is much
simpler to use.

···

--
Posted via http://www.ruby-forum.com/.

@Joel - thanks for your interest, But I managed it as below:

driver.find_elements(:name,"btnAddRequest").each{ |elem|

if elem.attribute(:value) == 'Add Bizz2' then

#print elem.attribute(:value)
elem.click
break

end

}

···

--
Posted via http://www.ruby-forum.com/.

FYI, this is the watir-webdriver equivalent. Much simpler, shorter, and
more readable.

driver.button({name: 'btnAddRequest', value: 'Add Bizz2'}).click

···

--
Posted via http://www.ruby-forum.com/.

Humm,

I will definitely look into the `watir-webdriver` anyways. :slight_smile:

Let me first grasp the whole logic of selenium-webdriver,then I will
taste it.

Thanks

···

--
Posted via http://www.ruby-forum.com/.