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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:42:06+00:00 2026-05-28T06:42:06+00:00

I am having trouble selecting an item from a Javascript dropdown (i.e. the items

  • 0

I am having trouble selecting an item from a Javascript dropdown (i.e. the items in the drop list are not hidden in DOM tree, they are not present at all until link is clicked). I have tried using the Actions class in ways like this:

    Actions cursor = new Actions(driver);
    cursor.moveToElement(linkThataDropsMenu).perform();
    cursor.click();

I have tried using the clickAndWait() function but it apparently does not exist in the Java webDriver libraries, and I have tried many variations of pausing and clicking in my code, including clicking twice. clickAndHold() also does nothing.

Below is the DOM tree after the menu has been generated. The only thing that changes on clicking is the insertion of div class=”menu”

<div id="divIdActive_2" class="data number active" style="min-height: 21px;">
<a class="opencnl" href="#">
    <span id="opencnlSpan" class="active" style="background-color: 
                             transparent;">800-852-2222</span>
</a>
<img class="tollFree" title="Display name(s) for Toll free function properly on 
                     Verizon Wireless devices, but may be omitted by other carriers on 
                     their devices." src="img/nil.gif">
<input id="customNum" type="hidden" value="8008522222" name="number_2">
<div class="menu">
    <a class="edit" href="#">Change Custom Number</a>
    <a class="copy" href="#">Copy Settings for 0 Selected Lines</a>
    <a class="clear" href="#">Clear Settings For this Line</a>
</div>
</div>

Here’s the strange part though – I can get the menu to drop from the IDE, using click() or clickAndWait(), and the exact same locator. From my Java code I can use my locators to gather the text of the element I want to click, but I can’t click the element. I have hundreds of other click commands in my Java code that work perfectly well, but not here. Any ideas? Thanks for reading at least!

  • 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-28T06:42:07+00:00Added an answer on May 28, 2026 at 6:42 am

    I got it! The trick was to mouse over the item, then click, then mouse over the item again, which leaves the cursor there, and then grab the newly rendered objects. My guess now is that before I added that second moveToElement(), as soon as the click happened the cursor was done doing everything it was asked to do and was garbage collected. Here’s my code for that – hope it helps somebody!

        Actions cursor = new Actions(driver);
        cursor.moveToElement(customNumberLink).perform();
        cursor.click();     
    
        // move to SAME element to leave cursor where it is while Javascript runs.
        cursor.moveToElement(customNumberLink).perform();
    
        // now grab newly generated elements
        WebElement clearLink = customNumberCell.findElement(By.cssSelector("a.clear"));
        clearLink.click();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble selecting items from a list of domain objects based on a
I'm having trouble selecting the input value from this html: <li class=t-item> <div class=t-mid>
I am having trouble selecting a hidden form field value that is a part
I'm having trouble finding out the proper syntax for selecting from a table all
I'm having trouble selecting for an element on my DOM. How do you select
Possible Duplicate: select all checkboxes command jquery, javascript I am having trouble selecting all
I'm having trouble using prev() in jQuery where it's not selecting the right element.
so I'm having trouble selecting a field only if another fields value is not
We are using asp.net mvc and having trouble in selecting the list of approved
I'm having bit of a trouble selecting correct values from my mysql sql server.

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.