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

  • Home
  • SEARCH
  • 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 8407315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:19:39+00:00 2026-06-09T23:19:39+00:00

Assume I have this html code: <select id=superior size=1 name=superior> <option value=></option> <option value=c.i.e.m.md.Division_1>DIVISION007</option>

  • 0

Assume I have this html code:

<select id="superior" size="1" name="superior">
    <option value=""></option>
    <option value="c.i.e.m.md.Division_1">DIVISION007</option>
    <option selected="selected" value="c.i.e.m.md.Division_$$_javassist_162_119">MyDivision</option>
    <option value="c.i.e.m.md.Division_121">MyDivision4</option>
    <option value="c.i.e.m.md.Division_122">MyDivision5</option>
</select>

So this is a combo box with

id=superior 

and currently value MyDivision is selected.

Using Selenium WebDriver I am trying to get the selected value, but no success.

I tried:

String option = this.ebtamTester.firefox.findElement(By.id(superiorId)).getText();
return option;

But this returns me all the values in the combobox.

Help please?

Edit:

WebElement comboBox = ebtamTester.firefox.findElement(By.id("superior"));
SelectElement selectedValue = new SelectElement(comboBox);
String wantedText = selectedValue.getValue();
  • 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-09T23:19:41+00:00Added an answer on June 9, 2026 at 11:19 pm

    This is written in C#, but it shouldn’t be hard to transition it over to any other language you’re using:

    IWebElement comboBox = driver.FindElement(By.Id("superior"));
    SelectElement selectedValue = new SelectElement(comboBox);
    string wantedText = selectedValue.SelectedOption.Text;
    

    SelectElement requires you to use OpenQA.Selenium.Support.UI, so at the top, type

    using OpenQA.Selenium.Support.UI;
    

    Edit:

    I suppose for you, instead of ‘driver’ you would use

    IWebElement comboBox = this.ebtamTester.firefox.FindElement(By.Id("superior"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume you have the following code: function name() { $(this).css('background', 'red'); } $('selector1').click(name); $('selector2').click(function
Assume that I have some HTML code, like this (generated from Markdown or Textile
Assume I have executed this js code: var container=function() { //do something } container.a=function
Assume that I have this piece of code: @interface Foo : NSObject { Bar
So I have this piece of code, and let's assume I'm filling out a
Say I have this <table border=1 id=tbl> <tr> <td><input type=checkbox name=vehicle value=Bike /></td> <td>row
i have this code: <html xmlns:fb=https://www.facebook.com/2008/fbml> <body> <script src=http://connect.facebook.net/en_US/all.js></script> <div id=fb-root></div> <script> // assume
I have a simple question: I have this code: # open an HTML file
Assume I have this model : class Task(models.Model): title = models.CharField() Now I would
Assume I have this domain object... public class SpansMultipleTables { public int CommonID {get;

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.