7stud2
(7stud --)
19 March 2013 07:51
1
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/ .
7stud2
(7stud --)
19 March 2013 08:57
2
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/ .
7stud2
(7stud --)
19 March 2013 09:41
3
@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/ .
7stud2
(7stud --)
22 March 2013 09:04
4
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/ .
7stud2
(7stud --)
25 March 2013 16:47
5
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
···
--
Posted via http://www.ruby-forum.com/ .