简体   繁体   中英

Protractor Won't Select From Drop-Down in IE10

For tests run on firefox and chrome, I often use a command similar to the following to select a particular option from a select2 drop-down menu:

element(by.cssContainingText('.select2-result-label', 'A')).click();

In firefox, you can see that it selects the item from the list. In IE, I can see the list drop down, and then it's like the cursor just flies up and down the list for a moment, but never seems to light on the right item and never selects anything.

Has anyone else seen different behavior with menus in IE and firefox?

With IE it always comes to "special" handling.

You can try scrolling into view of the element before clicking:

var selection = element(by.cssContainingText('.select2-result-label', 'A'));
browser.executeScript("arguments[0].scrollIntoView();", selection.getWebElement());
selection.click();

Alternatively, perform the click via executeScript() :

browser.executeScript("arguments[0].click();", selection.getWebElement());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM