This is a migrated thread and some comments may be shown as answers.

Difference between .Click and .MouseClick?

5 Answers 587 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Humberto
Top achievements
Rank 1
Humberto asked on 31 Mar 2015, 09:40 PM
Hello, I'm wondering what is the difference between those two methods mentioned above?  Is the .Click() method executed via Javascript?  What about the .MouseClick() method..does it not use javascript.

If I use the .MouseClick() event, does that mean that the browser has to to have top most focus on it while executing the tests?  Does that also mean that a user has to be logged in and the browser can't be minimized while the tests are running.

Please help me understand the difference at the low technical level...why would I prefer one over the other?  If I use the .MouseClick() method will I see the mouse cursor actually moving over to the UI element that it's about to interact with?

Regards,

Humberto

5 Answers, 1 is accepted

Sort by
1
Cody
Telerik team
answered on 01 Apr 2015, 08:41 PM
Hello Humberto,

.Click() - A click event for the target element is injected directly into browsers DOM. Works most of the time, but bypasses some event handlers, such as jQuery events that may be attached to the target element.

Can be used on a locked machine.


.MouseClick() - Injects a Windows mouse click event at a specific screen coordinate (calculated based on the target elements current screen position). The mouse cursor actually moves. Windows passes the mouse event to whichever window has focus at those coordinates. Normally this window would be the browser window, but not necessarily. It is possible to cause inject mouse clicks for screen coordinates outside of the browser window. Will cause any and all event handlers to be activated by the click.

Can NOT be used on a locked machine. Require a fully interactive desktop to work.


Does that help?


Regards,
Cody
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Humberto
Top achievements
Rank 1
answered on 01 Apr 2015, 09:01 PM
Hello Cody, it most definitely does.

Seems to me that both methods have disadvantages.  The javascript .Click() can be "flaky" and a developer might have to write up extra code to ensure that an event (.onblur, for example) actually gets fired/triggered?

Whereas the OS native .MouseClick() method is a security issue/concern since a user must be logged in and the tests have to be up and running and visible on the screen?  That would mean that any tests using "truer to user" actions will never be able to be part of a headless browser execution?
0
Accepted
Cody
Telerik team
answered on 01 Apr 2015, 10:03 PM
Hi Humberto,

Yes you've got it... there are pros and cons both ways. No matter what the user must be logged on. You cannot launch a browser if no user is logged on. You can't even initiate a Test Studio test of no user is logged on.

As for the security risk question, there are VM viewers out there that allow you to disconnect the session and leave it running "headless: just fine. Microsoft Hyper-V manager is one such product. I'm sure there are others.


Regards,
Cody
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Humberto
Top achievements
Rank 1
answered on 02 Apr 2015, 03:01 PM
Thank you Cody.

I think trying to go for Hyper-V would put us in another playing field.  I am not familiar with it and don't know about its costs.  We are definitely not in the cloud market and what I'm reading right now seems to indicate that Hyper-V is for that crowd.  Pitting Hyper-V vs. vSphere.

Wouldn't just running VirtualBox or VMWare with an instance of Windows in it be sufficient to have a "headless" machine on it?  Am about to try it right now.
0
Cody
Telerik team
answered on 02 Apr 2015, 08:22 PM
Hi Humberto,

Just FYI, Hyper-V is not really a cloud solution. It's more like a direct competitor to VMWare. You setup a physical server as a VM server. Then create as many VM's on that box as desired. I use the Hyper-V Manager to connect and disconnect to/from my VM's running on this box as needed. They are left running and do pass, even those requiring an interactive desktop.

I agree Hyper-V is not a cheap solution as it requires both beefy hardware and a not-so-cheap Microsoft license. I have no idea the actual cost myself, it may cost the same as VMWare.

I've never used VirtualBox or VMWare myself, so I cannot say if it would or would not work. it might and, if you already have it, it's worth a try. The one thing I do know is that making the connection to the VM through Microsoft Remote Desktop connection, then disconnecting that session is not sufficient.


Regards,
Cody
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Humberto
Top achievements
Rank 1
Answers by
Cody
Telerik team
Humberto
Top achievements
Rank 1
Share this question
or