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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:20:11+00:00 2026-05-19T01:20:11+00:00

I have 2 selects for setting the expiration date on a credit card and

  • 0

I have 2 selects for setting the expiration date on a credit card and I want to test that the error messaging comes back correctly when the card is expired. The only problem I have is that right now I can’t pick a value that’s expired since the list starts at Jan 2011 which isn’t expired yet. What I’m thinking about doing is using javascript in selenium to inject a known expired value. Anyone have any idea on how to do this or suggestions on a better way to accomplish?

  • 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-19T01:20:11+00:00Added an answer on May 19, 2026 at 1:20 am

    You can use the storeEval method to run snippets of JavaScript using Selenium. The JavaScript is run in the context of the Selenium object so you need window.document to get the document reference (hence the reason for the first line).

    This snippet is the JavaScript for adding a new option the select element:

    var d = window.document;
    var select = d.getElementsByName("selectName")[0];
    var option = d.createElement('option');
    option.value='Value';
    option.innerHTML='My new option';
    select.appendChild(option);
    

    Here’s the copy/paste of my Selenium IDE entry for you.

    <tr>
     <td>storeEval</td>
     <td>var d = window.document;var select = d.getElementsByName(&quot;selectName&quot;)[0];var option = d.createElement('option');option.value='Value';option.innerHTML='My new option';select.appendChild(option);</td>
     <td></td>
    </tr>
    

    Then you can just have the standard select method in Selenium to select the option. Of course, you can always do option.setAttribute('selected',true) in the JavaScript snippet but having Selenium do it will ensure the new value has been selected (since it will fail if it can’t find it).

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

Sidebar

Related Questions

I have a query that selects rows in a ListView without having a limit.
I have button that a user selects and I pop up a AlertDialog to
I have a series of two chained selects using ajax that work great. I
I have a simple procedure that selects 1000 rows from a table. For the
I have some code that first selects an option value in a dropdown menu
I have a form that has a few select dropdowns, and I want to
Let's say that I have a site where once the user selects a few
I want to edit corresponding labels when the user selects a row. i have
All, I have multiple selects on my page all with the same class. The
I have been porting oracle selects, and I have been running across a lot

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.