How to access the listBox option style ?

Aug 16, 2012 at 7:49 PM

Hello,

I have a listbox with 6 items and some of the items are display color is green. In my test case, I need to validate the item color is changed from Black to "Green". Here is html code.

<td vAlign="bottom" style="padding-top: 5px; padding-right: 10px; padding-bottom: 0px; padding-left: 10px; background-color: rgb(208, 208, 208);">
<select tabIndex="30" id="lbRegionSelected" onchange="RegionOrResourceChanged( 'Region' )" size="8">
<option id="RegionItem0" style="color: green;" value="0">
Text - West Europe
<option id="RegionItem1" style="color: black;" value="1">
<option id="RegionItem2" style="color: black;" value="2">
<option id="RegionItem3" style="color: green;" value="3">
How can I access the style of a particular option in a listbox ? Appreciate your help.
Thanks,
Sailaja 


 

 


Coordinator
Aug 21, 2012 at 9:15 AM

Hi Sailaja,

You can try to use the ControlDefinition property of the unwrapped control.

Also see the same question posted in the msdn forums:

http://social.msdn.microsoft.com/Forums/en-US/vsautotest/thread/c26f6e72-4341-4e41-8969-828bfab09d0a/

Aug 23, 2012 at 10:04 PM
Thank you for your response.
I tried ControlDefinition property of the unwrapped control. The only value it is getting is "select tabIndex="30" id="lbRegionSelected" onchange="RegionOrResourceChanged( 'Region' )" size="8"" .

But not the Option string (option id="RegionItem0" style="color: green;" value="0")

I am looking for the Option value.

Thanks,
Sailaja
On Tue, Aug 21, 2012 at 2:19 PM, icnocop <notifications@codeplex.com> wrote:

From: icnocop

Hi Sailaja,

You can try to use the ControlDefinition property of the unwrapped control.

Also see the same question posted in the msdn forums:

http://social.msdn.microsoft.com/Forums/en-US/vsautotest/thread/c26f6e72-4341-4e41-8969-828bfab09d0a/

Read the full discussion online.

To add a post to this discussion, reply to this email (cuite@discussions.codeplex.com)

To start a new discussion for this project, email cuite@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com




--
Thanks,
Sailaja Nalamati
Coordinator
Aug 24, 2012 at 8:43 AM

Hi Sailaja,

Please try the GetChildren method to enumerate the child object of the CUITe_HtmlList.

Then you will have access to the value of the ControlDefinition property of the child controls to assert on.

Aug 24, 2012 at 11:08 PM
Thank you for your response.

I tried using GetChildren method.

string teststring = pgSubmitServiceOrder.lstRegion0.UnWrap().GetChildren().GetEnumerator().ToString();

It is returning "Microsoft.VisualStudio.TestTools.UITesting.UITestControlCollection+<GetEnumerator>d__0".

I am not getting the value which I am expecting. Appreciate your help.

Thanks,
Sailaja

On Fri, Aug 24, 2012 at 1:44 AM, icnocop <notifications@codeplex.com> wrote:

From: icnocop

Hi Sailaja,

Please try the GetChildren method to enumerate the child object of the CUITe_HtmlList.

Then you will have access to the value of the ControlDefinition property of the child controls to assert on.

Read the full discussion online.

To add a post to this discussion, reply to this email (cuite@discussions.codeplex.com)

To start a new discussion for this project, email cuite@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com




--
Thanks,
Sailaja Nalamati
Coordinator
Aug 24, 2012 at 11:17 PM

Hi Sailaja,

You can see the sample unit test in the latest code called "HtmlUnorderedList_WithListItems_CanAssertOnListItems":

        [TestMethod]
        public void HtmlUnorderedList_WithListItems_CanAssertOnListItems()
        {
            CUITe_BrowserWindow bWin = CUITe_BrowserWindow.Launch(CurrentDirectory + "/TestHtmlPage.html", "A Test");

            CUITe_HtmlUnorderedList list = bWin.Get<CUITe_HtmlUnorderedList>("id=unorderedList");

            IEnumerable<CUITe_HtmlListItem> children = from i in list.GetChildren()
                                                       select i as CUITe_HtmlListItem;
            Assert.AreEqual(3, children.Count());

            Assert.AreEqual(1, children.Count(x => x.InnerText == "List Item 1 "));
            Assert.AreEqual(1, children.Count(x => x.InnerText == "List Item 2 "));
            Assert.AreEqual(1, children.Count(x => x.InnerText == "List Item 3 "));

            bWin.Close();
        }