Unable to focus element for select2 - protractor test

Using this solution to test select2 and for some reason I am getting below error.

Any suggestion on what I should be looking for?

code

 this.select2First = function(select2Locator, opt_query) {
    // the 'a' element inside the select2 will receive the 'mousedown' event
    var selector = select2Locator + ' a.select2-choice select2-default';
    // Locator for the select2 options
    var options = element.all(by.css('.select2-results-dept-0'));

    // select2 doesn't activate on click 
    // and protractor doesn't have a direct mousedown method on 'ElementFinder'.
    browser.driver.executeScript('$(arguments["0"]).mousedown();', (selector));

    if (opt_query) {
        browser.driver.switchTo().activeElement().sendKeys(opt_query);
        // select2 can fetch options from over a network
        // so we confirm that all pending network requests are resolved after typing the query
        browser.driver.wait(function () {
            return browser.driver.executeScript('return $.active === 0;');
        }, 2000);
    }

    // makes sure all the options are rendered
    browser.driver.wait(function () {
        return options.count().then(function (count) {
            return 0 < count;
        });
    }, 2000);

    options.first().click();
}

      

Mistake

UnknownError: unknown error: cannot focus element
  (Session info: chrome=42.0.2311.135)
  (Driver info: chromedriver=2.14.313457(3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Windows NT 6.3 x86_64) (WARNING: The server did not provide any stacktrace information)

      

Command duration or timeout: 30 milliseconds

+3
angularjs selenium-webdriver protractor angularjs-e2e


source to share


No one has answered this question yet

See similar questions:

2
Protractor how to check select2

or similar:

721
How do I set focus to an input field?
106
Should I use Protractor or Karma for my end-to-end testing?
63
How can I check if an element has a class using Protractor?
2
Mac Giving Error Test Drive - No Result After 10 Seconds
2
How can I get this checkbox item back using Protractor?
1
Can the protractor localize and validate list items created with ng-for boot angle symbols?
0
The transporting element all counts back
0
element.all always returns count as 0
-1
Error running protractor tests (unknown error: updateWindow not set)



All Articles
Loading...
X
Show
Funny
Dev
Pics