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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:41:18+00:00 2026-06-11T09:41:18+00:00

When writing functional tests, how can I set the value of a select box

  • 0

When writing functional tests, how can I set the value of a select box if I only have the label of the option I want, but not the actual value?

  • 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-11T09:41:19+00:00Added an answer on June 11, 2026 at 9:41 am

    I’m not sure I got exactly what you need, I suppose you have a form like this

    <form action="..." method="post">
        ...
        <select id="my_form_category" name="my_form[category]"> 
            <option value="1">category1</option>
            <option value="2">category2</option>
            <option value="3">category3</option>
       </select>
       ...
       <button type="submit">Edit</button>
    
     </form>
    

    and you want to select category2. Even if you don’t know the option value you can use the crawler to extract it

    $client = static::createClient();
    // go to form
    $crawler = $client->request('GET', '...');
    $value = $crawler->filter('#my_form_category option:contains("category2")')->attr('value');
    $form = $crawler->selectButton('Edit')->form();
    $form['my_form[category]']->select($value);
    // ... set other values
    $client->submit($form);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing up a set of unit-tests for my MVC4 application. I want to
I'm writing some tests in Perl which have a fair amount of set up.
I am writing an application where many (but not all) ActiveRecord models have a
I started writing functional tests for my rails app today. I use the RESTful
I'm writing some unit tests and I have a lot of functions of the
I'm currently writing a set of unit tests for a Python microblogging library, and
I am a totally noob in writing jUnit tests. I have an Android program
While writing functional tests for a controller, I came across a scenario where I
I'm writing a functional test for a legacy Python script so that I can
I've been teaching myself functional programming, and I'm currently writing different higher order functions

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.