Reputation: 1307
I am trying to write a test that enters some text into a Froala JS editor instance, in Selenium IDE 2.9.1 (Firefox 45). I'm not able to determine any way to specify the clientX
and clientY
parameters to this event, which apparently Froala code is relying on to make the editor function properly.
If I use Selenium IDE's mouseOver
command, there is no ability to specify these coordinates (it does not have a corresponding mouseOverAt
command, as some other mouse events do). Using simply fireEvent
command, with mouseover
as the value, I cannot specify any parameters to that native JS event.
How can I send a mouseOver
event to a particular element, with these coordinates, in Selenium IDE?
Upvotes: 1
Views: 345
Reputation: 156
Do it in an Execute Script (JavaScript) step: I found this: How to Move Mouse Cursor to a Specific Location using Selenium in Java? https://www.geeksforgeeks.org/how-to-move-mouse-cursor-to-a-specific-location-using-selenium-in-java/ and this: How To Find Web Elements X Y Coordinates Using Selenium WebDriver https://www.softwaretestingmaterial.com/find-web-elements-x-y-coordinates-using-selenium-webdriver/
How to simulate a click by using x,y coordinates in JavaScript?
document.elementFromPoint(x, y).click();
function click(x, y) { var ev = new MouseEvent('click', { 'view': window, 'bubbles': true, 'cancelable': true, 'screenX': x, 'screenY': y });
var el = document.elementFromPoint(x, y);
el.dispatchEvent(ev);
}
Upvotes: 0
Reputation: 669
As far as I know there is no good way to specify mouse coordinates using javascript. Since Selenium IDE is based on Javascript most probably it is impossible to set mouseover for specific coordinates. At least that's what I think.
But there is the way to change text in the Froala element anyway:
open | https://www.froala.com/wysiwyg-editor
getEval | window.document.evaluate( "//*[@id='froala-editor']//div[@class='fr-element fr-view']//h1",window.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue.innerHTML='CROCODILE!!! ARRR!!!'
It seems pretty complex but adding a text is even more complex.
open | https://www.froala.com/wysiwyg-editor
getEval | var addedH1 = window.document.createElement("h1"); addedH1.innerHTML = 'Added text'; window.document.evaluate( "//*[@id='froala-editor']//div[@class='fr-element fr-view']//h1/..",window.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue.appendChild(addedH1);
That is the only way I can suggest I hope it will help.
Upvotes: 1