1

As selenium allows to execute java script, i want to click and double click on webelement or x,y co-ordinate using java script. I want to use java script because the underlined webelement is a Flash/svg objects on browser.

Please let me know how to double click using java script on a flash/svg webelement.

Thanks in advance... Srinivas - Willing to learn new things :)

Srinivas JN
  • 11
  • 1
  • 4
  • 1
    is your flash button is exposed? .. As per I know you can't use selenium for same. use sikuli for same , as you want to learn a new thing ;) :D :) – Shubham Jain Oct 15 '15 at 07:45
  • :) :D :) i like it :P "as you want to learn a new thing" Yep, I and my team are using Sikuli for automating flash/svg and we are getting much success over there. But the problem is that Sikuli actions cannot be multi threaded, and hence this question. I foresee that using javascript with selenium, multi threading is possible. Please help me with this question. – Srinivas JN Oct 15 '15 at 08:53
  • flash button is not exposed to qa. More over, we are migrating from flash to fully functional SVG. – Srinivas JN Oct 15 '15 at 08:54
  • Actually javascript is working directly on DOM but how we can suppose to perform operation using javascript even when the button is not exposed. It's seems impossible to me and If in case we can then I also love to know that :) – Shubham Jain Oct 15 '15 at 08:57
  • for same you need a channel(plug-in) which can interact between js and flash components. – Shubham Jain Oct 15 '15 at 08:59
  • refer it :- http://code.tutsplus.com/tutorials/quick-tip-how-to-communicate-between-flash-and-javascript--active-3370 – Shubham Jain Oct 15 '15 at 09:01
  • I never tried but if it helps then it will be awesom :) – Shubham Jain Oct 15 '15 at 09:01
  • In DOM at x,y location, java script can perform click/double click and selenium can execute the javascript on dom, and hence i guess we can. Lets see how it goes. I am trying this, on success, i will publish here. – Srinivas JN Oct 15 '15 at 09:07
  • Yes, I have post an refer link in below answer as well but want to tell you that co-ordinate of element can change according to different environment, it also depend on OS, pixel and resolutions.. So your script can be fail in different environments – Shubham Jain Oct 15 '15 at 09:10

1 Answers1

1

Use below code :

Actions action = new Actions(driver);   
 WebElement element = driver.findElement(By.xpath(your_xpath));

   action.doubleClick(suite_name); 
   action.perform();
Mosam Mehta
  • 1,658
  • 6
  • 25
  • 34
  • Thanks Mosam Mehta, but as i said selenium/Action class related clicks are not working as it is flash/svg based elements. I know the co-ordinates of the elements and i want java script to click / double click the element. – Srinivas JN Oct 15 '15 at 08:38
  • in that case refer:- http://stackoverflow.com/questions/3277369/how-to-simulate-a-click-by-using-x-y-coordinates-in-javascript – Shubham Jain Oct 15 '15 at 09:06
  • Thanks, similarly i am looking for double click. – Srinivas JN Oct 15 '15 at 10:05
  • Coming to co-ordinate changes, yes i agree but i will not hard code the co-ordinates, each time i take it from ui in some way. I will always refer to dynamic and at time co-ordinates only. – Srinivas JN Oct 15 '15 at 10:06