Selenium webdriver CSS attribute reading

I have the below kind HTML :



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.

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.

@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

}

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

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

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