Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8858681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:53:01+00:00 2026-06-14T14:53:01+00:00

Ho do I select the first item in a SelectList in WatiN? Below you

  • 0

Ho do I select the first item in a SelectList in WatiN? Below you can see how I have my selectlist declared and below that is how I’m attempting to call the select. I don’t see any options for index. Will I need to get a string collection of selected items and select by the [1] string or is there a simpler way to do this?

Page Class:

[FindBy(Id = "VariationRelationshipId")]
public SelectList VariationRelationship { get; set; }

Test Class:

//need to select 1st item in list
Browser.Page<MyPage>().VariationRelationship........
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:53:02+00:00Added an answer on June 14, 2026 at 2:53 pm

    You need to be calling against an instance of a browser, not the Watin.Core.Browser class

    Test code.

    IE myBrowser = new IE(true);
    myBrowser.GoTo("http://www.tizag.com/htmlT/htmlselect.php");           
    myBrowser.Page<DropDownSample>().States.WaitUntilExists();
    myBrowser.Page<DropDownSample>().States.Options[2].Select();  //<-- not Browser.Page....
    

    Class

    public class DropDownSample : Page
        {
            [FindBy(Name = "selectionField")]
            public SelectList States { get; set; }
        }
    

    Above checked on Watin2.1, IE9, Win7 – runs like a champ. Selects “conneticut” in the first select list on the page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can select the first item in the div using $('.class:first') Now since I
In code-behind I can do this to select something: // Select item in first
I have an HTML select list (let's call it List A) that is dynamically
I'm trying to select the first line item ( <li> ) with the class
I'm using AJAX with struts1.x, In my application once select the first select item
I have first: select url from urls where site = '$value' order by url
I have the following jQuery method that iterates over a selectlist containing a number
I just want to select the first item by default but the drop down
I have a form with a select list, where the user can select anywhere
I have an IDictionary I need to select the first Foo where the Bar.Prop1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.