Selenium webdriver is having trouble selecting a value from an ajax dropdown

I am currently facing an issue where I am attempting to choose specific values from two Ajax drop down fields. The first drop down list opens up, but it is not selecting any options, which in turn prevents the second drop down list from populating. This error message shows up:

org.openqa.selenium.NoSuchElementException: Unable to locate element: option[value="111"].

Any assistance would be greatly appreciated as I am still new to working with Selenium.

Below is the code snippet that I am currently using:

HTML Block:

Answer №1

The reason for this problem is due to a compatibility issue with Firefox browser (version 45). I am currently using selenium 3.0.0-beta2 and testing against Firefox 45.0.2

After attempting to use geckodriver (version 0.10.0) on Windows 10 - 64 bit, it appears that something is not functioning correctly. Geckodriver only seems to work properly with Firefox 48 or later versions. However, it is running smoothly with chromedriver.

Answer №2

If you're looking to enhance your dropdown interaction in selenium, consider taking a more specialized approach. Give this code snippet a try:

Select dropMenu = new Select(driver.findElement(By.id("cmbJob")));
dropMenu.selectByValue("111");

For added convenience, you can create a function specifically for handling dropdowns:

protected void chooseOptionByValue(String selectId, String value) {
  Select dropMenu = new Select(driver.findElement(By.id(selectId)));
  dropMenu.selectByValue(value);
}

This allows you to easily utilize the function like so:

chooseOptionByValue("cmbJob", "111");

The Selenium dropdown object offers various other functionalities such as selectByText, among others. Explore its capabilities further in the API documentation here: https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/Select.html

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exploring the Diversity of Forms with Ajax and JQuery

$(document).ready(function () { $("#addrow").click(function () { var newRow = '<tr><td><input type="text" class="item_code form-control" placeholder="Item Code" name="item_code[]"></td><td><input type="text" ...

Concealing/Revealing Elements with jquery

For hours, I've been attempting to switch between hiding one element and showing another in my script. Here is the code I am using: <script type="text/javascript"> function () { $('#Instructions').hide(); $('#G ...

What is the best way to indicate progress as the canvas resizes an image?

Is there a way for me to access progress updates? My main focus is on receiving progress information, regardless of how it will be displayed. I may choose to use a progress bar in the future, but my current inquiry pertains solely to obtaining the data it ...

I am experiencing issues with my buttons not functioning properly after implementing the fetch API in conjunction with express.js

I'm facing a peculiar issue with buttons that are meant to display templates on the client page. This code is executed on the client side. The primary function of this class is to allow the user to click a button, send a request, receive a response c ...

When working with three.js, I am able to successfully display a .glb 3D model locally. However, when trying to view it on the GitHub server

While working on my personal webpage, I attempted to use three.js to showcase a 3D model. The model appeared successfully on my local server, but failed to display on my web server, resulting in an error message similar to the following: https://i.sstatic. ...

Troubleshooting a CSS problem with iPad browsers

I have a specific issue related to CSS on iPad. I am working with a set of sublinks and have defined the styles in CSS as follows: #leftNav .searchBySub {...} #leftNav a.searchBySub:hover {...} #leftNav .searchBySubClicked {...} In my JavaScr ...

Retrieving data from MongoDB for rendering on an HTML page

I have successfully inserted data into my MongoDB database, but I am facing issues with the "get" function to display this data on my HTML page. My current setup involves using Node.js with Express framework and Angular for front-end development and routi ...

Is the jQuery ajax .done() function being triggered prematurely?

Struggling with a problem here. I'm dealing with this code (simplified): var initializeZasilkovna = function () { // Initialize object window.packetery.initialize(); }; // Check if the object doesn't exist if (!window.packetery) { // It ...

How can you personalize the dropdown button in dx-toolbar using DevExtreme?

Currently, I am working with the DevExtreme(v20.1.4) toolbar component within Angular(v8.2.14). However, when implementing a dx-toolbar and specifying locateInMenu="always" for the toolbar items, a dropdown button featuring the dx-icon-overflow i ...

Comparison of a floating point (primitive data type) using the == operator

Exploring float comparison using the == operator: String sFloat = "0.0"; float n = Float.parseFloat(sFloat); System.out.println("n--"+n); if(n == 0){ System.out.println("inside if"); } else{ System.out.println("inside else"); } Is comparing float ...

When the Json payload is lengthy, an Ajax request to an ASP.NET MVC Controller results in a 404 error

I am facing an issue with my ajax call that involves passing a json string to a controller action. When the content portion of the json is too long, or when the json string in general exceeds a certain length, the server returns a 404 error. However, if I ...

Exploring JSON information containing colons in the labels

I am having trouble accessing JSON data in Angular that contains a colon in the label (refer to responsedata). This is the code causing issues: <li ng-repeat="i in items.autnresponse.responsedata | searchFor:searchString"> <p>{{i.autn:numhits} ...

Performing numerous asynchronous MongoDB queries in Node.js

Is there a better way to write multiple queries in succession? For example: Space.findOne({ _id: id }, function(err, space) { User.findOne({ user_id: userid }, function(err, user) { res.json({ space: space, user: user}); }); }); It can g ...

Retrieving JSON array data in Android via a URL getPath

I am new to Android app development and currently working on an app that displays information about items in the game Guild Wars 2. You can find the data here. My goal is to read the entire list of items including their name, price, and icon, and display t ...

Having trouble getting Typescript code to function properly when using commonjs style require statements

I am completely new to Typescript, Node.js, and Express. Following the instructions outlined in this tutorial (https://www.digitalocean.com/community/tutorials/setting-up-a-node-project-with-typescript), I set up my project exactly as described there. The ...

What is the recommended method for establishing synchronous communication between the client and server during calls?

My client-server communication involves making multiple calls where each call depends on the previous one to finish and return a value before initiating the next one. Below is a simplified version of my current approach: Client: function doOrder() { v ...

sending object value to directive rather than other data variables

I have been attempting to customize the functionality of this functioning http://jsfiddle.net/markcoleman/JNqqU/. In the current fiddle, the object is directly assigned where I am trying to change it to $scope.obj.items. However, passing the object to the ...

How can I spin the entire canvas in React JS using react-three-fiber?

I recently followed a tutorial from Codrops on creating a scrollable site using react-three-fiber. However, I made some changes like centering all the items and removing the RGB split effect. Now, I want to achieve a diagonal scroll effect by rotating the ...

Finding the xpath that retrieves all dropdown values in Selenium WebDriver

I have encountered an issue in my HTML code where there is no select tag for options. However, when clicking on a select dropdown item, the name of the dropdown item appears in the HTML code. enter image description here public void user_count_list_ ...

Error: Unable to access 'createInvite' property from undefined variable

Having trouble generating an invite to one of my guild's channels. Here is the code snippet I am using: const { Client } = require("discord.js"); const client = new Client({ intents: [] }); client.on("ready", async () => { ...