What exactly does the term "dropdown protractor code" refer to

The dropdown has the attribute ng-model ="text.abc" and displays the text text="Test":

<md-select id="select_55" class="ng-pristine ng-untouched ng-valid ng-valid-required" required="" aria-label="queuingModel: SKILL_GROUP" ng-model="text.abc" md-on-close="vm.changeQueue(vm.queue.resourcePoolType)" name="resourcePoolType" tabindex="0" aria-disabled="false" role="listbox" aria-expanded="false" aria-multiselectable="false" aria-owns="select_container_56" aria-required="false" aria-invalid="false" style="">
<md-select-value id="select_value_label_51" class="md-select-value">
<span>
<div class="md-text ng-binding">SKILL_GROUP</div>
</span>
<span class="md-select-icon" aria-hidden="true"></span>
</md-select-value>

This code cannot be used:

element(by.model('text.abc')).$('[value=" ?"]').click(); 

As I do not have a value for the dropdown.

What would be the Protractor code to interact with this dropdown in such a scenario?

Answer №1

If you wish to choose a value based on its text:

let optionToChoose = "SKILL_GROUP";

let dropdownElement = element(by.model('text.abc'));
dropdownElement.click();

dropdownElement.element(by.xpath(".//div[contains(@class, 'md-text') and . = '" + optionToChoose + "']")).click();

Answer №2

What do you think of this suggestion?

Use element(by.id(dropdownList)).sendKeys("value");

Alternatively, you could try:

element(by.model(dropdownModel)).sendKeys("value");

Answer №3

Give this code a try.

// Choose Category
element.all(by.model('dropdown')).each(function (eachElement, index)
{
     eachElement.click();
     browser.driver.sleep(500);
     element(by.model('text.abc')).click();
     browser.driver.sleep(500);
});

Hopefully this solution is helpful :) Check out this link for additional insights.

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

Incorporating PHP generated content into Dart without using Ajax

My current website is built using PHP (Laravel) on the server side and Javascript on the client side. Now, I am interested in replacing the Javascript with Dart. Currently, I inject data into the Javascript on the webpage like this: <script> va ...

It seems like the SelectElement in WebDriver is malfunctioning

I am new to Selenium and I am currently learning how to manipulate dropdown lists. I initially had trouble with the .SelectBy methods, so I decided to go back to basics and try using the SelectElement.Options method. Here is the HTML code for a dropdown l ...

iOS iframe remains unscrollable only when switching from portrait to landscape orientation

I have a scrollable iframe set up on iOS like this: <div style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; overflow: scroll; -webkit-overflow-scroll: touch; ..."> <iframe style="height: 600px, ..."> </iframe> </d ...

Choosing specific rows in a kogrid by clicking on a button within a column

My kogrid includes a single column with a view button for each row. I would like to show a popup containing the values of the selected row when the View button is clicked. How can I retrieve the values of the selected row in order to pass them into the p ...

Utilizing Promise.all with map and async functions in Node.js ensures non-blocking behavior during function calls

After developing a small module to communicate with Zookeeper and retrieve a list of service endpoints, everything seems to be working smoothly except for the part where the list of endpoints is returned. Within the module, there is a function that is supp ...

How to add a service to a static function in Angular

After incorporating a logger service into my project, I have encountered an issue with using it in NGXS static selectors. The selectors in NGXS are static methods, which prevent me from accessing the logger service injected via Angular DI. Are there any e ...

Extract attributes from a string of HTML containing name-value pairs

Here is a sample string that I need to work with '<img id="1" data-name="test" src="img_01.jpg" />' My goal is to extract the attribute name and value pairs from the string, create the element, and apply these attributes. I have come up ...

Switch between various div elements

Looking for a way to toggle between different divs? Here's the scenario: You have a sidebar with a set of buttons. Upon entering the page, you only want the div containing the button group to be visible. However, when a specific button (e.g. Info) is ...

Encountering an error while attempting to change pages using selenium.click()

I'm experiencing an issue where I am unable to click on a div to navigate to the next page of a table, even though the URL remains the same. Both the previous and next page divs have identical classes. I have attempted: elem = driver.find_element_by_c ...

Facing an issue with Axios in React Native where I am unable to POST a Blob or File

After capturing an image with react-native-image-picker, I am attempting to upload the raw data of the picture using Axios. I managed to create a blob by fetching the image URI and converting it like so: const file = await fetch(response.uri); const theBl ...

What is the most effective way to determine which radio button is currently selected in a group with the same name using JQuery?

<form class="responses"> <input type="radio" name="option" value="0">False</input> <input type="radio" name="option" value="1">True</input> </form> Just tested: $('[name="option"]').is(':checked ...

Tips for effortlessly moving rows between Grid views using drag and drop functionality

driver.findElement(By.xpath(".//*[@id='tbplayers']/tbody/tr[2]/td[3]")).click(); WebElement dragme = driver.findElement(By.xpath(".//*[@id='tbplayers']/tbody/tr[2]/td[3]")); WebElement drop = driver.findElement(By.xpath(".//*[@id=&ap ...

a method for inserting a space after a certain character, with the exception of when that character is located at the start or end of a line

I've created a regular expression that can modify various patterns like: anything1 * anything2* anything3 anything1* anything2 * anything3 anything1 * anything2 * anything3 anything1*anything2 *anything3 anything1 * anything2 *anything3 anything1*any ...

Guide to converting a two-dimensional square matrix stored as a one-dimensional array in JavaScript

My inquiry is similar to the one linked below, however, I am seeking a solution using JavaScript How to Transpose 2D Matrix Stored as C 1D Array In essence, I have a square matrix in two dimensions 1 2 3 4 5 6 7 8 9 This matrix is stored like this let ...

What is the best way to direct users to an input field within a dynatree title?

I am currently utilizing Dynatree to display a tree view, and my goal is to focus on an input field within the dynatree title element. However, I am encountering an issue where the focus is being lost. My code attempts to address this problem but unfortun ...

Retrieving particular excerpts from a block of text that includes the keyword "javascript."

I have a chunk of string containing HTML source code. Currently, I am trying to read specific tags that I need using JavaScript. Since I am new to programming, I'm unsure how to proceed. Can anyone assist me with this? The issue lies in the following ...

Tips on how to interact with a button labeled <input type =Button> when using Selenium

What is the correct way to click on a button when the input type is set to button? The code I am using doesn't seem to work. <p> <img class="getdata-button" style="float:right;" src="/common/images/btn-get-data.gif&qu ...

Tips on maintaining the Parent menu in a hovered state when the mouse is over the child menu within a Dropdown Menu

I have been working on creating a dropdown menu that functions correctly. However, I am facing an issue where the top menu, when hovered, turns white, but as soon as I move down to the submenus, the top menu reverts back to its original color. Is there a ...

Using Backbone.js to Persist Information on the Server

Currently, I'm in the process of integrating my Backbone.js application with the server. One thing to mention is that I have customized my sync function in the collection to utilize jsonp: window.Project = Backbone.Model.extend({ initialize:func ...

Angular mouseenter event delay not functioning after initial trigger

Currently, I am attempting to create a delay for the mouseenter event when the user hovers over a div. The goal is for the video to start playing only after the user has hovered for at least 1 second. Initially, everything works as expected, but after the ...