Possibly. I don't quite follow though. Any chance you could post the exact HTML in the state where it fails, and the test code? Then iI'll get to the bottom of it for you.
Adrian
<tr style="height: 25px"> <td class="formlabel"> <span id="ContentPlaceHolder1_ContentPlaceHolder1_lbl4" title="Single or Multi-Category events can be selected by checking the relevant box.">Category</span> </td> <td style="text-align: left" id='cols'> <select size="4" name="ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder1$ddlCategory" multiple="multiple" id="ContentPlaceHolder1_ContentPlaceHolder1_ddlCategory" style="width:178px;"> <option selected="selected" value="64">Candy</option> <option selected="selected" value="65">Chocolate</option> <option value="66">Coffee</option> <option value="67">Snacks</option> </select> </td> </tr> <tr style="height: 25px"> <td class="formlabel"> <span id="ContentPlaceHolder1_ContentPlaceHolder1_Label2">PPH</span> </td> <td style="text-align: left" id='pgcols'> <select size="4" name="ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder1$ddlProductGroup" multiple="multiple" id="ContentPlaceHolder1_ContentPlaceHolder1_ddlProductGroup" class="normal" style="width:178px;"> <option selected="selected" value="1347">Africana asortate </option> <option selected="selected" value="484">Africana Creme Base</option> <option value="485">Africana Plain Base</option> <option value="612">Chokotoff 250g stand 10 kg 2010</option> <option selected="selected" value="490">Halls Base</option> <option value="491">Halls Breezers</option> <option selected="selected" value="479">Lila Collection</option> <option value="583">Milka winter 100g</option> <option value="882">MILKA AMAVEL 160G</option> <option value="615">Milka Bomboane de pom 400g</option> <option value="1643">Milka Bunny 60g Ciocolata cu lapte din Alpi</option> <option value="511">Milka Crème base</option> <option value="512">Milka Crème Sourcherry</option> <option value="513">Milka Desert</option> <option value="1644">Milka Kleine Eier Milch creme 75g</option> <option value="1349">Milka LED Spring</option> <option value="607">Milka limited edition 240g</option> <option value="514">Milka Luflee</option> <option value="515">Milka Milkinis large</option> <option value="516">Milka Milkinis small</option> <option value="616">Milka Mos Craciun 20x60g</option> <option value="517">Milka plain base</option> <option value="518">Milka plain Diet</option> <option value="519">Milka plain WholeNuts</option> <option value="520">Milka pralines 120g</option> <option value="1352">Milka pralines 137.5g</option> <option value="521">Milka pralines 150g</option> <option value="522">Milka pralines 42g</option> <option value="593">Milka Seasonals - all the rest</option> <option value="545">Milka snax big</option> <option value="546">Milka snax small</option> <option value="584">Milka summer</option> <option value="523">Milka Tablets Base 200g/250g</option> <option value="554">Milka Tablets Base 200g/250g/300g</option> <option value="524">Milka Tablets Base 300g</option> <option value="525">Milka Wholenuts250g</option> <option value="617">Milka winter</option> <option value="618">M-JOY Alune 60g</option> <option value="619">M-JOY Lapte 60g</option> <option value="594">Poiana 200g Base</option> <option value="533">Poiana Aerata</option> <option value="534">Poiana Baton 30g</option> <option value="842">Poiana Chokotoff 238g</option> <option value="480">Poiana Chokotoff 266g</option> <option value="481">Poiana Chokotoff 38g</option> <option value="482">Poiana Chokotoff 95g</option> <option value="535">Poiana Chokotoff Intense</option> <option value="536">Poiana Crème Base</option> <option value="538">Poiana Delicii Base</option> <option value="1351">Poiana LED Spring</option> <option value="540">Poiana Monopraline</option> <option value="558">Poiana Monopraline Sour Cherry</option> <option value="541">Poiana Plain Base</option> <option value="483">Poiana Praline Asortate</option> <option value="595">Poping candy</option> <option value="596">Smash 50g</option> <option value="1355">Stand I love Milka </option> <option value="547">Tassimo</option> <option value="621">Toblerone alune si stafide 400g</option> <option value="611">TOBLERONE OBO 200g Easter'11</option> <option value="622">Toblerone Snowtop 100g</option> <option value="542">Toblerone Tablets Base</option> <option value="599">X-mas Candy</option> </select> </td> </tr> <tr style="height: 25px"> <td class="formlabel"> <span id="ContentPlaceHolder1_ContentPlaceHolder1_lbl5" title="Single or Multi-Brand events can be selected by checking the relevant box.">Brand</span> </td> <td style="text-align: left" id='bcols'> <select size="4" name="ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder1$ddlBrandList" multiple="multiple" id="ContentPlaceHolder1_ContentPlaceHolder1_ddlBrandList" style="width:178px;"> <option selected="selected" value="345">Africana</option> <option value="349">Halls</option> <option selected="selected" value="351">Milka</option> </select>
The scripts I have coded are as follows (I need to open the list before selecting the check boxes, and click outside the list to close them due to how they are written):
if (!string.IsNullOrEmpty(category))
{
//Create the array
List<string> categoryarray = ArrayMaker.CreateArray(category, category1, category2, category3);
//Open the list selection
_eventPage.FindCss("a#ContentPlaceHolder1_ContentPlaceHolder1_ddlCategory.multiSelect").Click();
foreach (var value in categoryarray)
{
//Click the object(s)
_eventPage.Check(value);
}
//To close the list selection, click elsewhere in the screen
_eventPage.FindCss("input#ContentPlaceHolder1_ContentPlaceHolder1_txtName.textbox").Click();
}
//Select the product groups if they are not empty
if (!string.IsNullOrEmpty(pph))
{
//Create the array
List<string> ppharray = ArrayMaker.CreateArray(pph, pph1, pph2, pph3);
//Open the list selection
_eventPage.FindCss("a#ContentPlaceHolder1_ContentPlaceHolder1_ddlProductGroup.multiSelect").Click();
foreach (var value in ppharray)
{
//Click the object(s) - the Check method passes here as the text is unique
_eventPage.Check(value);
}
//To close the list selection, click elsewhere in the screen
_eventPage.FindCss("input#ContentPlaceHolder1_ContentPlaceHolder1_txtName.textbox").Click();
}
//Select the product brands if they are not empty
if (!string.IsNullOrEmpty(brand))
{
//Create the array
List<string> brandarray = ArrayMaker.CreateArray(brand, brand1, brand2, brand3);
//Open the list selection
_eventPage.FindCss("a#ContentPlaceHolder1_ContentPlaceHolder1_ddlBrandList.multiSelect").Click();
foreach (var value in brandarray)
{
//Click the object(s)
//_eventPage.Check(value); - this fails but the next line passes
_eventPage.FindXPath(".//*[contains(@id,'ContentPlaceHolder1_ContentPlaceHolder1_ddlBrandList')]//following-sibling::*//label[contains(text(), '" + value + "')]").Click();
}
//To close the list selection, click elsewhere in the screen
_eventPage.FindCss("input#ContentPlaceHolder1_ContentPlaceHolder1_txtName.textbox").Click();
}
On Monday, 2 July 2012 21:40:23 UTC+1, Adiel wrote:
Possibly. I don't quite follow though. Any chance you could post the exact HTML in the state where it fails, and the test code? Then iI'll get to the bottom of it for you.
Adrian
I know that the way the multi selects were written are not the expected, but the HTML (that is generated after the selections are made as before the 2nd and 3rd drop-downs would be empty until the previous drop-down selections are made) is as follows:<tr style="height: 25px"> <td class="formlabel"> <span id="ContentPlaceHolder1_ContentPlaceHolder1_lbl4" title="Single or Multi-Category events can be selected by checking the relevant box.">Category</span> </td> <td style="text-align: left" id='cols'> <select size="4" name="ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder1$ddlCategory" multiple="multiple" id="ContentPlaceHolder1_ContentPlaceHolder1_ddlCategory" style="width:178px;"> <option selected="selected" value="64">Candy</option> <option selected="selected" value="65">Chocolate</option> <option value="66">Coffee</option> <option value="67">Snacks</option> </select>
foreach (var value in categoryarray)
{
It does work with multiple selects, I just tested it. Check is designed for checkboxes only. Have you tried this?_eventPage.Select(value).From("ddlCategory");
}
I realise that for many options in the same <select> this might be a bit inefficient as it will find the "ddlCategory" element once for each option. I had not thought about this before so think I will add an overload which takes an IEnumerable<string> so you could do: BrowserSession.Select(categoryarray).From("ddlCategory")And I suppose we also need this for multiple selects too:BrowserSession.Unselect(option).From(select)
But in the meantime can you give the Select(..).From(..) API a go and let us know how you get on?".//*[contains(@id,'ContentPlaceHolder1_ContentPlaceHolder1_ddlBrandList')]//following-sibling::*//label[contains(text(), '" + value + "')]"
As I can't use XPath as a way to define the select list I will continue to find the element with the XPath to click.
Cheers,
Helen