0

Is there any alternative for protractor's mouseMove? I would like the mouse to hover over the menu. But it appears to be unsupported with geckodriver.

So far I've tried, browser.executeScript('arguments[0].mouseMove()', element(by.className('menu')));

But get this error, Failed: TypeError: arguments[0].mouseOver is not a function.

Thanks :)

Isabella
  • 133
  • 1
  • 2
  • 13

2 Answers2

0

There are two error usage in your script.

Firstly, Protractor element() api return an ElementFinder which is a wrapper upon HTML Web Element. But the arguments[0] in arguments[0].mouseMove() require a HTML Web Element. This rule is apply to all browser, not only required by Firefox.

You need to call getWebElement() on ElementFinder to get the Web Element as below.

Secondly, HTML Web Element does not has the mouseMove() api, but mousemove event.

browser.executeScript(
    // web element not has mouseMove() api,
    // so below usage is wrong.
    'return arguments[0].mouseMove();', 
    element(by.className('menu')).getWebElement()
);
yong
  • 13,357
  • 1
  • 16
  • 27
  • Hi @yong, thanks for your reply. I tried the following, `browser.executeScript( 'return arguments[0].mousemove;', menuArea.getWebElement());` But it doesn't appear to hover over the menu icon as intended. Do you have any suggestions? Thanks :) – Isabella Oct 16 '18 at 21:12
0

I managed to solve it :) Thanks for your help.

Here's what I found worked,

browser.executeScript( 'return arguments[0].click();', browser.driver.findElement(by.className('menu')));

Isabella
  • 133
  • 1
  • 2
  • 13