Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

373
Views
How to handle dynamic Elements in Dropdown in Java Selenium

I want to select a values in dropdown. and my problem is. I can't locate the specific element as they are dynamic and they will just appear in the inspect elements Once I choose a value in dropdown.

and I can't right click and inspect element the values in dropdown when the dropdown is open as it will close as soon as I left click.

I also can't use "Select" class as they are embedded in "div" html element

I also can't use "SendKeys" as the dropdown don't have textfield

Here are the codes I tried to use.

//try #1
        driver.findElement(dropDown).click();
        JavascriptExecutor js = (JavascriptExecutor)driver;
        ((WebElement) js.executeScript("document.getElementById('dropwDownID).value='VALUE I WANT'")).click();

note: when I tried this script("document.getElementById('dropwDownID).value='VALUE I WANT') in the console, it returns the value I want.

//try #2
        driver.findElement(dropDown).click();
        WebDriverWait wait = new WebDriverWait(driver, 30);
        wait.until(ExpectedConditions.elementToBeClickable(this_Element_Only_Appear_When_I_Choose_A_Value));

Please see attached picture

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!