Using AngularJS ng-model to select options in a dropdown menu with WebDriver

In the following code snippet, an AngularJS based dropdown menu is implemented:

<select _ngcontent-c1="" class="form-control ng-pristine ng-valid ng-touched">

After opening the list, I attempted to select a variable from this list using the code below:

driver.findElement(By.xpath("//*[contains(text(), '"valuetobeselected"')]")).click();

Answer №1

This is the code that will solve your issue.

Select dropdownMenu = new Select(driver.findElement(By.xpath("xpathtodropdown")));
dropdownMenu.selectByVisibleText("value");

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

What is the best way to determine the correct xpath to locate and access all profiles on a webpage utilizing Selenium and Python?

As a beginner in the world of programming, I have embarked on an exciting journey to create a test software for automating data retrieval from a website. Despite my enthusiasm, I am encountering challenges in defining the xpath that would allow me to locat ...

The output of PHP is not being captured by Ajax

I have a JavaScript code that calls a PHP script to retrieve a value, but it's not working as expected. Here is my JavaScript code: $.ajax({ type: 'GET', url: '/home/example.com/ftp/www/typo3conf/ext/quiz_rs/pi1', data ...

Verify the current webpage's URL on your browser

As I delve into utilizing the powerful Selenium libraries, a specific task has caught my attention. I am on a mission to determine the current URL that is being viewed in any open browser, not just a browser opened through a web driver. The question arises ...

Difficulty accessing class functions from the test application in Node.js NPM and Typescript

I created an NPM package to easily reuse a class. The package installs correctly and I can load the class, but unfortunately I am unable to access functions within the class. My project is built using TypeScript which compiles into a JavaScript class: For ...

Leveraging a combination of AngularJS directives within a single div element

Why can't I use multiple directives in the same div tag in AngularJS? The product names from the module are not displayed with the following HTML code: <!DOCTYPE html> <html ng-app="gemStore"> <head> <title></ti ...

Navigating and Organizing in Ionic Service Factory

Apologies for the beginner question. I am looking to incorporate filtering and sorting by name on my webpage. However, I have encountered two issues after attempting to implement this functionality using a factory in services.js: When typing a search ter ...

Filtering data precisely in an AngularJS controller

$scope.gradeC = $filter('filter')($scope.results.subjects, {grade: 'C'})[0]; This code snippet will return the filtered results that match the grade criteria. Does anyone have suggestions on how to filter for only exact matches? ...

Restrict the number of dynamic form elements to a maximum of 10 entries

I am working on a feature where users can refer their friends and the data will be saved in a database. <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <script type='text/javascript' sr ...

Exploring the capabilities of WebDriver

While I may not be an expert in OOP, there's something that has been on my mind regarding Selenium WebDriver: It seems like all examples and tutorials for Selenium WebDriver use WebDriver objects, like this: WebDriver driver = new FirefoxDriver(); d ...

How to troubleshoot issues with Firefox 22 using FireBug 1.73 and possibly FirePath 0.9.7

<pAfter configuring my version setup, I find myself facing compatibility issues when using Firefox 22 with Selenium WebDriver 2.35. Although the Firebug UI appears complete, the "Inspect Element" feature does not function properly. Upon e ...

Navigating through concatenated JSON strings in a web browser: A step-by-step guide

I am currently using Socket.IO to transmit data to the browser. The information being sent is a continuous stream of JSON objects, which upon arrival at the browser, transforms into a single large JSON string. However, the issue I am encountering is that t ...

Tips for personalizing error messages for the "required" field by utilizing a dictionary feature on VeeValidate in Vue.Js

I am trying to update the error message that appears when an input field with the "cpf" rule is left empty (meaning it does not meet the "required" rule). I believe using the "dictionary method" with custom messages is the solution, but I am struggling to ...

Nuxtjs is incorporating the Vue-pano component for enhanced functionality

When using vue-pano with Nuxtjs, I encountered the error message: "window is undefined". If I import it like this: <script> import Pano from 'vue-pano' export default { components: { Pano } } </script> I then tried using a ...

Issue with SelectByVisibleText method

selectByVisibleText() method is not working properly when trying to select text from a drop down menu. While running the code, the drop down menu appears to be functioning correctly and the cursor hovers over the desired text, but for some reason, it fail ...

Properties of the State Object in React Redux

I'm curious as to why my state todos were named todo instead of todos in the redux dev tools. Where did that name come from? There is no initial state, which makes me wonder. I'm currently following a Udemy course by Stephen Grider, but I am wor ...

What is the best way to transfer variables between two Vue files?

How can I transfer a variable between two Vue files? Hello, in my SendCode.vue file, I have a variable named NewEmail that I would like to use in another file called changePass.vue. Is there any way to do this? Can someone offer assistance? Thank you</p ...

Customizing AxiosRequestConfig with Axios in TypeScript can greatly enhance the functionality and

Currently working with React and Axios. Lately, I've been experimenting with custom configurations in Axios as shown below: import $axios from 'helpers/axiosInstance' $axios.get('/customers', { handlerEnabled: false }) However, wh ...

Assigning ng-model within a nested ng-repeat to use as parameters in an ajax request

How can I make an ajax call using ng-model values as parameters in my AngularJS project? Is it allowed to set ng-model to json data directly? Also, how should I set the scope for ng-model in the controller? Controller EZlearn.controller("testController", ...

What is the most effective method for exchanging variables between programs or threads?

I currently have a program that executes an algorithm processing real-time data. Once per hour, the algorithm's parameters are optimized based on new historical data. Currently, this optimization process is running in a single thread, pausing the rea ...

Error 404 encountered while trying to access a website with parameters using Vue.js

Currently, I am in the process of building a website using VueJS and recently discovered how to use url parameters. Everything was working perfectly on my local machine - I could easily navigate to different pages by including parameters in the URL. For e ...