Fire onMouseOver() event programmatically
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.
javascript selenium browser-automation
add a comment |
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.
javascript selenium browser-automation
Did you tryonmouseover()instead ofmouseover()?onmouseoveris 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 <protocol>://<domain>:<port> 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 2: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
– Angel D
Dec 29 '18 at 17:15
@Taplar I have triedmouseover()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
add a comment |
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.
javascript selenium browser-automation
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.
javascript selenium browser-automation
javascript selenium browser-automation
edited Dec 29 '18 at 16:36
No Refunds No Returns
5,40441936
5,40441936
asked Dec 28 '18 at 23:21
jmknight2jmknight2
246
246
Did you tryonmouseover()instead ofmouseover()?onmouseoveris 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 <protocol>://<domain>:<port> 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 2: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
– Angel D
Dec 29 '18 at 17:15
@Taplar I have triedmouseover()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
add a comment |
Did you tryonmouseover()instead ofmouseover()?onmouseoveris 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 <protocol>://<domain>:<port> 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 2: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
– Angel D
Dec 29 '18 at 17:15
@Taplar I have triedmouseover()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
Did you try
onmouseover() instead of mouseover()? onmouseover is the event property– Taplar
Dec 28 '18 at 23:23
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 <protocol>://<domain>:<port> as that of the page it is on?
– Taplar
Dec 28 '18 at 23:25
Though I also have to ask if the website in the iframe has the same <protocol>://<domain>:<port> 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 2:29
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 2: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
– Angel D
Dec 29 '18 at 17:15
In order to use Selenium with iFrame you should switch context with 'this.Browser.SwitchTo().Frame(idFrameWebElement)'. Please see Selenium and iFrame in HTML
– Angel D
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
@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
add a comment |
1 Answer
1
active
oldest
votes
The trouble is, the web-page uses iFrames which is making Selenium less than intuitive.
Try the kantu selenium ide plus the free xmodule addon. This addons adds the xclick and xmove commands that simulate real user mouse clicks. These commands do not operate on the browser DOM so they work well for triggering mouse events inside iframes, frames and canvas elements.
To fire onMouseOver() event programmatically you use:
xmove | (image of place to click) | #move
iframe example macro here: automate embedded video
kantu has also a command line so you can use it from within your code.
I was hoping to find a solution with less overhead than bringing a Chrome extension into the mix, but I believe your solution may be the only solution. I'm continuing the automation with Kantu as of now. Thank you for the suggestion!
– jmknight2
Dec 31 '18 at 20:38
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53965335%2ffire-onmouseover-event-programmatically%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The trouble is, the web-page uses iFrames which is making Selenium less than intuitive.
Try the kantu selenium ide plus the free xmodule addon. This addons adds the xclick and xmove commands that simulate real user mouse clicks. These commands do not operate on the browser DOM so they work well for triggering mouse events inside iframes, frames and canvas elements.
To fire onMouseOver() event programmatically you use:
xmove | (image of place to click) | #move
iframe example macro here: automate embedded video
kantu has also a command line so you can use it from within your code.
I was hoping to find a solution with less overhead than bringing a Chrome extension into the mix, but I believe your solution may be the only solution. I'm continuing the automation with Kantu as of now. Thank you for the suggestion!
– jmknight2
Dec 31 '18 at 20:38
add a comment |
The trouble is, the web-page uses iFrames which is making Selenium less than intuitive.
Try the kantu selenium ide plus the free xmodule addon. This addons adds the xclick and xmove commands that simulate real user mouse clicks. These commands do not operate on the browser DOM so they work well for triggering mouse events inside iframes, frames and canvas elements.
To fire onMouseOver() event programmatically you use:
xmove | (image of place to click) | #move
iframe example macro here: automate embedded video
kantu has also a command line so you can use it from within your code.
I was hoping to find a solution with less overhead than bringing a Chrome extension into the mix, but I believe your solution may be the only solution. I'm continuing the automation with Kantu as of now. Thank you for the suggestion!
– jmknight2
Dec 31 '18 at 20:38
add a comment |
The trouble is, the web-page uses iFrames which is making Selenium less than intuitive.
Try the kantu selenium ide plus the free xmodule addon. This addons adds the xclick and xmove commands that simulate real user mouse clicks. These commands do not operate on the browser DOM so they work well for triggering mouse events inside iframes, frames and canvas elements.
To fire onMouseOver() event programmatically you use:
xmove | (image of place to click) | #move
iframe example macro here: automate embedded video
kantu has also a command line so you can use it from within your code.
The trouble is, the web-page uses iFrames which is making Selenium less than intuitive.
Try the kantu selenium ide plus the free xmodule addon. This addons adds the xclick and xmove commands that simulate real user mouse clicks. These commands do not operate on the browser DOM so they work well for triggering mouse events inside iframes, frames and canvas elements.
To fire onMouseOver() event programmatically you use:
xmove | (image of place to click) | #move
iframe example macro here: automate embedded video
kantu has also a command line so you can use it from within your code.
edited Dec 31 '18 at 14:41
answered Dec 31 '18 at 14:20
Tim VanderzeilTim Vanderzeil
3935
3935
I was hoping to find a solution with less overhead than bringing a Chrome extension into the mix, but I believe your solution may be the only solution. I'm continuing the automation with Kantu as of now. Thank you for the suggestion!
– jmknight2
Dec 31 '18 at 20:38
add a comment |
I was hoping to find a solution with less overhead than bringing a Chrome extension into the mix, but I believe your solution may be the only solution. I'm continuing the automation with Kantu as of now. Thank you for the suggestion!
– jmknight2
Dec 31 '18 at 20:38
I was hoping to find a solution with less overhead than bringing a Chrome extension into the mix, but I believe your solution may be the only solution. I'm continuing the automation with Kantu as of now. Thank you for the suggestion!
– jmknight2
Dec 31 '18 at 20:38
I was hoping to find a solution with less overhead than bringing a Chrome extension into the mix, but I believe your solution may be the only solution. I'm continuing the automation with Kantu as of now. Thank you for the suggestion!
– jmknight2
Dec 31 '18 at 20:38
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53965335%2ffire-onmouseover-event-programmatically%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Did you try
onmouseover()instead ofmouseover()?onmouseoveris 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 <protocol>://<domain>:<port> 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 2: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
– Angel D
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