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.
on 2013-03-19 08:51
on 2013-03-19 09:57
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.
on 2013-03-19 10:41
@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
}
on 2013-03-22 10:04
FYI, this is the watir-webdriver equivalent. Much simpler, shorter, and
more readable.
driver.button({name: 'btnAddRequest', value: 'Add Bizz2'}).click
on 2013-03-25 17:47
Humm, I will definitely look into the `watir-webdriver` anyways. :) Let me first grasp the whole logic of selenium-webdriver,then I will taste it. Thanks
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.