0

I'm attempting to automate some of the tedious tasks involved in our email security protocols. Unfortunately, our email security provider's API doesn't include endpoints for 90% of the functions we need. As such, I've opted to employ Selenium for some browser automation. The trouble is, the web-page uses iFrames which is making Selenium less than intuitive.

As of now, I'm attempting to invoke the onMouseOver event handler of an element from a small snippet of executed JS. However, I've been depressingly unsuccessful. I've yet to find anyway to actually simulate a mouse pointer moving over an element.

Here is some of what I've tried so far that hasn't worked:

document.mcFrame1.document.querySelector("#menu_0").mouseover()

var eventMouseOver = new Event('pointerover'); document.mcFrame1.document.querySelector("#menu_0").dispatchEvent(eventMouseOver)

Any help would be greatly appreciated.

No Refunds No Returns
  • 8,092
  • 4
  • 32
  • 43
jmknight2
  • 99
  • 2
  • 10
  • Did you try `onmouseover()` instead of `mouseover()`? `onmouseover` is the event property – Taplar Dec 28 '18 at 23:23
  • Though I also have to ask if the website in the iframe has the same ://: as that of the page it is on? – Taplar Dec 28 '18 at 23:25
  • You can try selenium ide (browser extension), so you can record any action as a macro, then you can check actions/selectors in that macro. – Mike Twc Dec 29 '18 at 02:29
  • In order to use Selenium with **iFrame** you should switch context with 'this.Browser.SwitchTo().Frame(idFrameWebElement)'. Please see [Selenium and iFrame in HTML](https://stackoverflow.com/questions/18924146/selenium-and-iframe-in-html) – Angel Dinev Dec 29 '18 at 17:15
  • @Taplar I have tried `mouseover()` to no avail. The iframe is coming from a different origin URL which is causing a cross-origin error, however I got around that by turning off Chrome's security with `--disable-web-security`. – jmknight2 Dec 31 '18 at 20:35

0 Answers0