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 7624511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:59:00+00:00 2026-05-31T04:59:00+00:00

I have a select control on my site. I am using page objects to

  • 0

I have a select control on my site. I am using page objects to interact with the page. If I do (with the first 2 lines under my class and the selectByValue in my method)

@FindBy(id="foo")
private Select foo;

foo.selectByValue("myValue");

It fails with a null pointer. I also tried without the @FindBy.

Now if I do this in my method it all works fine and selects the correct item

Select foo = new Select(sDriver.findElement(By.id("foo")));
foo.selectByValue("myValue");

Here is the actual web snippet for that control (edited to protect the innocent)

<select id="foo" name="service_name">
    <option selected="selected" value="one">one</option>
    <option value="two">two</option>
    <option value="three">three</option>
</select>

Let me say that I have a work around for my issue but I don’t get why the “normal” path is not working.

  • 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-05-31T04:59:01+00:00Added an answer on May 31, 2026 at 4:59 am

    Thats because the Select class has this constructor:

    Select(WebElement element)
    

    See the Javadoc

    So if you do something like this:

    @FindBy(id="foo")
    private WebElement wannabeSelect;
    Select realSelect = new Select(wannabeSelect);
    realSelect.selectByValue("myValue");
    

    It should work.

    BTW, I am using the same approach as you in the “workaround” because I dont wanna cast new WebElement object when I need Select object. But anyways, the

    sDriver.findElement(By.id("foo"));
    

    returns WebElement, so thats why its working. You can also do this:

     WebElement wannabeSelect = sDriver.findElement(By.id("foo"));
     Select foo = new Select(wannabeSelect);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a control on my Site.Master page which pulls data from an
I have a select control, and in a javascript variable I have a text
I have a segmented control where the user can select how to order a
I'm trying to select an element from my webpage... I have inserted a control
I have a user control which contains the following code: <form id=CurrencyForm method=post runat=server>
I have login control on my asp.net web site with custom Authenticate does it
I have an ASP.Net GridView control on an ASPX page hosted on a SharePoint
In my Summary page, I have two CalendarExtender controls to enable someone to select
I'm using the Textpattern CMS to build a discussion site-- I have a firm
I have a main page which looks like: <%@ Page Title= Language=C# MasterPageFile=~/Views/Shared/Site.Master Inherits=System.Web.Mvc.ViewPage

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.