Commit to choosing an option from a dropdown menu using TypeScript

I just started learning about typescript and I have been trying to create a promise that will select options from a drop down based on text input. However, my current approach doesn't seem to be working as expected:

case 'SelectFromList':
     return new Promise( (resolve, reject) => {
         this.retrieveElement(driverscr.getPageElementFromJson(screenName, fieldName)) // retrieveElement gets the page element.
             .click()
             .then(() => {
                 resolve();
             })
             .thenCatch( () => {
                 reject();
             });
       });

Answer №1

As previously mentioned, I have not attempted to choose an item from a dropdown in the manner you are currently doing. Here is a method that has been successful for me in the past. In this example, there is a dropdown menu containing a list of domains to which I wish to add a user. I locate the option that corresponds to the desired domain and click on it. I hope this approach assists you in reaching a resolution.

public static domainSelectorList = element.all(by.repeater("d in vm.customer.domains")

public static addUserToDomain(domain: string): Promise<void> {
    return this.domainSelectorList.filter((elem: ElementFinder) =>
        elem.getWebElement()
            .getInnerHtml()
            .then((innerHtml: string) =>
                innerHtml.indexOf(`@${domain}`) > -1)).first().click();
}

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

Angular 4: Unidirectional data flow from View to Component

Struggling to secure user credentials in my Angular form due to 2-way data binding displaying encrypted values within the component. Here's the code snippet: <form> <div class="input-group"> <span class="input-group-a ...

Ionic's InnapBrowser not functioning properly

I have been using the InappBrowser plugin to open site pages within my application. However, I have encountered an issue where upon touching an item, the InappBrowser does not return or shows ADB error logs. Interestingly, when testing with ionic serve in ...

Angular 2+ Service for tracking application modifications and sending them to the server

Currently I am facing a challenge in my Angular 4 project regarding the implementation of the following functionality. The Process: Users interact with the application and it undergoes changes These modifications are stored locally using loca ...

Matching the appropriate data type for interface attributes

In the process of developing a module (module1), I have defined the following interface type: interface ModuleOneInterface { keyOne: customInterface; keyTwo: customInterface; keyThree: customInterface; } Now, as I work on another module (modul ...

Why is the package and launch activity not showing up in the Appium console?

Hello! I'm just starting out with Appium testing. I've been trying to add the apk file (selendroid apk file), but I'm having trouble getting the package name and launch activity on the appium console. I've tried various solutions like r ...

Is it possible to determine the type of a variable by simply clicking on it in IntelliJ (specifically in typescript)?

Having the ability to hover over a variable and see the expected type in TypeScript would be incredibly beneficial. I'm curious if there is some sort of internal static analysis being conducted that stores this information. Is there a method for acces ...

Enhance the input choices in Angular JS by incorporating additional input alternatives

Currently, I am working on a form that requires selecting a country from a list to add shipping costs to the total. This particular form utilizes the ngCart directive and requires the use of ng-click to send this information to the directive. The issue I ...

What is the process to access array elements in AngularJS?

When coding in HTML, <select class="element-margin-top" ng-model="vm.selectedRole" ng-options="(roleName,enabled) in vm.roleNames"> <option value="">All Roles</option>{{vm.roles[0]}} </select> I am tryin ...

Is it possible to combine ng-class with conditional expression and ng-class with string syntax in a single statement?

To assign classes based on the ngRepeat index, I am using ng-init="myIndex = $index". With this setup, I can apply classes like color-0, color-1, color-2, etc. by using ng-class='"color-" + myindex'. Furthermore, I need to add a different class ...

Properly incorporating a git+https dependency

I'm facing an issue while trying to utilize a git+https dependency from Github to create a TypeScript library. I've minimized it to a single file for illustration purposes, but it still doesn't work. Interestingly, using a file dependency fu ...

Implementing a filter function in Angular 2 and Ionic 2 that is dependent on *ngFor on a separate page

I recently created a simple ion-list along with a filter to display items based on a specific key:value pair. I'm not entirely sure if I've implemented it correctly, so any suggestions on a better approach would be greatly appreciated. LIST.HTML ...

Connecting with Service Providers for Access

Is it feasible to retrieve a provider typically utilized in a config from a service? The motive behind this is that I currently lack the necessary information to carry out the task within the module.config. The provider I am interested in accessing is the ...

Exploring TypeORM: Leveraging the In() function within @ManyToMany relationships

There are two main characters in my story: Hero and Villain (their profiles are provided below). How can I utilize the Encounter() method to identify all instances where the Hero interacts with the Villain based on an array of Villain IDs? I am seeking a ...

The JSON response from Angular contains a unicode character that is stripping away extra characters, resulting in an invalid JSON format

I am encountering an issue with a http response that contains a name with a unicode character (such as Müller) in IE11. The error message "Invalid Character" is appearing because IE11 treats the entire http response as a string within Angular's http ...

Is it possible to have Angular 2 code consolidated into one single file?

After completing the "Tour of Heroes: the vision" tutorial in Angular, I successfully created a working app. However, there is one aspect that is driving me crazy! The app currently has 334 requests and takes 7.6 seconds to load! Is there a way to combin ...

Should I deploy the Angular2 demo app within Rails or as its own standalone application?

Currently diving into the world of Angular2 and completing both the quickstart and heroes tutorial. Each time I start these applications, I use the "npm start" command. On top of that, I've developed a Ruby on Rails backend application alongside an A ...

Is it possible to utilize the node package ssh2 within a web browser environment?

I am working on a project for school where I am creating an SFTP client directly in my browser. I have successfully implemented the node package ssh2 and it works perfectly when running the code in the terminal. I can connect to the server, read directorie ...

Preventing parent click events in AngularJS when clicking on a child element: Tips and tricks

I am facing an issue with a <div> that has a ng-click directive, but this <div> contains a child element also with a ng-click directive. The problem arises when the click event on the child element also triggers the click event of the parent el ...

Using Python and Selenium for login, encountering difficulty in locating the div element

# _*_coding:utf-8_*_ from selenium import webdriver driver=webdriver.Chrome() url="https://login.alibaba.com" driver.get(url) driver.implicitly_wait(3) print(driver.page_source) driver.quit() Attempting to use Selenium for logging in, but unable to locat ...

When utilizing the JSON Wire Protocol, Selenium fails to employ the webdriver.firefox.profile feature

After launching the profile manager, I created a new profile named "foo" and set it as the default profile for Firefox. I then launched Firefox and closed it. Next, I started Selenium using the argument -Dwebdriver.firefox.profile=foo. The server's o ...