This is a migrated thread and some comments may be shown as answers.

HTML Select List Verification

1 Answer 65 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Siva
Top achievements
Rank 1
Siva asked on 11 Sep 2013, 08:15 PM
Hi

 I have a Html Select List box with Some String for Example
Test1
Test2
Test3

I need to Verify Test4 is not listed there.

Could help me in terms of code

Thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Boyan Boev
Telerik team
answered on 16 Sep 2013, 02:07 PM
Hi Siva,

Thank you for contacting us.

Here is a sample code:

bool isPresent = true;
HtmlSelect mySelect = ActiveBrowser.Find.ById<HtmlSelect>("select");
           foreach (HtmlOption item in mySelect.Options)
           {
               if (item.Text == "Test4'sText")
               {
                   isPresent = true;
                   break;
               }
               else
               {
                   isPresent = false;
               }
           }
           Assert.IsTrue(isPresent);

If there is no item with Test4'sText the test will fail.

Hope this helps.

Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Siva
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Share this question
or