July 14, 2009

verifyAttribute help w/Selenium for AMO?

Earlier today, I tried to write a Selenium testcase to help ensure that bug 504188 never happens again; the bug was that advanced-search parameters in our AMO 5.0.7 candidate weren't getting set properly.

View source on the following page, and grep for "Linux" -- we want to verify that whole line, basically:

* option 2 is selected
* has "Linux" in its value

In the Selenium IDE, we're checking for:

verifyElementPresent, //div[@id='advanced-search']/fieldset[2]/div[3]/label[@for='pid'], Value="Linux"

But this isn't working -- verifyElementPresent is happy and returns success/true, because it finds the element, and doesn't care about the value in Value=; I *think* verifyAttribute is what we want, instead, but Raymond, Juan, and I tried that tonight without success.

Help is appreciated!

Posted by stephend at July 14, 2009 8:20 PM
Comments

This :
1/ verifySelectedValue, id=pid, 2
2/ verifySelectedLabels, id=pid, Linux

works for me with Selenium IDE 1.0.2

Régis.

Posted by: Régis on July 15, 2009 12:37 AM

What you want is:

for HTML scripts:

verifySelected, pid, label=Linux

for Perl scripts:

$sel->selected_label_is("pid", "label=Linux");


I doubt you are interested to know that Linux has value=2. If you are interested to check this anyway, add:

for HTML scripts:

verifySelected, pid, value=2

for Perl scripts:

$sel->selected_label_is("pid", "value=2");


I hope you are using Perl scripts, because they are much more powerful than HTML scripts IMO. :)

Posted by: LpSolit on July 15, 2009 1:38 AM

Why not use "verifySelectedLabel, pid, Linux"? Or do you actually care about the order of choices? In which case you could add a second verification for "verifySelectedIndex, pid, 2",

As to the original check, you don't want label there, because that searches for <label for="pid"> not for the selected value. Label for pid has text()='Platform' and no value attribute.

To check for automatically selected element you could use "verifyElementPresent, //select[@id='pid']/option[@selected and ./text()='Linux'] but that only considers <option selected> in source which isn't the same as currently selected element if user has changed selection.

Posted by: Merike on July 15, 2009 1:40 AM
Post a comment