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

User.Click() not clicking in Silverlight application

14 Answers 286 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 2
Tim asked on 02 Oct 2013, 02:20 AM
Hello,
I've been cruising the forum for some time now looking for a solution to the problem I'm facing. I see many threads similar to the issue I'm seeing but I have yet to find a solution in those threads that solve the problem.

I've exported the tests to run independently from Test Studio using nunit in the console. I've gotten the test to kick off and run filling out a login form up to the point of clicking the Login button. I can see the button, verify its clickable, highlight it, etc. However, when I go to click it using User.Click(), nothing happens. I've enabled annotations and it shows the click action occurring, yet the button is not clicked

I've tried clicking it through FindName:
this.App.FindName<Button>("PART_LoginButton").User.Click();

I've tried through the exported method from Test Studio:
Pages.<PageName>.SilverlightApp.PARTLoginButtonButton.User.Click();
 Neither of those two methods work. In addition, I've also ensured that settings.Web.EnableSilverlight = true, tried refreshing the dom tree, clicking the silverlight app bounds to ensure that its selected, double clicking (single clicking twice), refreshing the visual trees, and even sleeping before clicking the button to ensure no AJAX type code is affecting the button.

Here is the source code of the button itself:
<button Name="PART_LoginButton" AutomationId="PART_LoginButton" Uid="65158171">
  <grid Uid="34157240">
    <border Name="Background" Uid="57177053">
      <textblock Name="textBlock" AutomationId="textBlock" Uid="44831437">Login</textblock>
    </border>
  </grid>
</button>

Any assistance to get this code clicking that button would be greatly appreciated!

Thank you,
Tim Harrison

Edit: Added button source code.

14 Answers, 1 is accepted

Sort by
0
Tim
Top achievements
Rank 2
answered on 03 Oct 2013, 05:07 PM
Anyone have some time to look at this? I've been stuck on this for weeks. Someone at least give me a glimmer of hope.
0
Daniel
Top achievements
Rank 2
answered on 03 Oct 2013, 08:19 PM
Not an expert in the realm of Silverlight applications (never automated or coded), but give this a shot if you haven't:

(format code block not working for me at the moment, plain text coding incoming!)

Pages.Cognistix.SilverlightApp.PARTLoginButtonButton.User.Click(ArtOfTest.WebAii.Core.MouseClickType.LeftClick);


Invoking the MouseClickType.LeftClick seemed to do the trick for me.  May need to use whole ArtOfTest.WebAii.Core.MouseClickType.LeftClick.

*EDIT*

Identifying the element entirely through code has worked for me as well.:

 

SilverlightApp app = ActiveBrowser.SilverlightApps()[0];

 app.Find.ByName<Button>("PART_LoginButton").User.Click(MouseClickType.LeftClick);

 

0
Tim
Top achievements
Rank 2
answered on 03 Oct 2013, 08:44 PM
Thanks Daniel for your reply.

I remember trying something similar from the direct export from Test Studio. I tried it again just now with no change in the behavior. It still acts like it clicks, but doesn't actually click.

Another thing I feel I should note is that the actual mouse cursor does not move to that location. I remember that happened when I executed the tests through Test Studio. Is that perhaps a hint as to what is wrong? Or is it the case that the cursor does not actually need to move in order for the click to actually happen (much like how Selenium works)?

So to add to the list of things I've tried:
Daniel's suggestion:
Pages.<PageName>.SilverlightApp.PARTLoginButtonButton.User.Click(ArtOfTest.WebAii.Core.MouseClickType.LeftClick);
As well as the direct export from Test Studio:
Pages.<PageName>.SilverlightApp.PARTLoginButtonButton.User.Click(ArtOfTest.WebAii.Core.MouseClickType.LeftClick, 0, 0, ArtOfTest.Common.OffsetReference.AbsoluteCenter, ArtOfTest.Common.ActionPointUnitType.Percentage);
0
Daniel
Top achievements
Rank 2
answered on 04 Oct 2013, 12:32 PM
I'm at a loss as to why it would not be functioning.  The only difference I can note at this point is I am running the test from Test Studio (or Visual Studio), instead of NUnit. 

I've tried repeated other methods of setting focus, clicking, not specifying clicktype, etc...and they have all worked.

I'll see if I can download and try NUnit today to reproduce the behavior you are experiencing.
0
Boyan Boev
Telerik team
answered on 07 Oct 2013, 08:39 AM
Hi Tim,

Thank you for contacting us.

Unfortunately I was not able to reproduce this behavior against a public application.

Since this is a specific application issue please:

1. Please provide us with a copy of your test and if it is possible grant us access to your application so we can reproduce the issue on our end and give you a solution. 

2. If direct access is not possible, capture a Fiddler trace and attach it to this support ticket in a zip file. If you are unfamiliar with how to do so, this link will provide you with step-by-step instructions for download and use. Please make sure to enable 'Decrypt HTTPS traffic' and 'Store binaries' options (see attached image) before starting capture.

3. A Jing video demonstrating the issue may also help us to better understand what is happening.

Hope to hear from you soon.

 

Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Andrey Cherepakha
Top achievements
Rank 1
answered on 31 Oct 2013, 02:44 PM
Hello!

I faced with the same problem on Win7 Professional SP1 64bit. 

Action: Button.User.Click();
Expected result: a button is clicked;
Actual result: a button is not clicked.

The same application works fine on WinXP SP3

I use WebAii 2011.2.1413.0, but also tried it with the latest version 2013.1.911.0

May 64bit cause the problem? Does WebAii support Win7 64bit?

Thanks
0
Boyan Boev
Telerik team
answered on 04 Nov 2013, 02:27 PM
Hello Andrey,

Thank you for contacting us.

As I said to Tim, we need to reproduce the issue on our end so we can debug it.

1. Please provide us with a copy of your test and if it is possible grant us access to your application so we can reproduce the issue on our end and give you a solution. 

2. If direct access is not possible, capture a Fiddler trace and attach it to this support ticket in a zip file. If you are unfamiliar with how to do so, this link will provide you with step-by-step instructions for download and use. Please make sure to enable 'Decrypt HTTPS traffic' and 'Store binaries' options (see attached image) before starting capture.

3. A Jing video demonstrating the issue may also help us to better understand what is happening.

4. Send us the trace log or any other error output which can helps us diagnose the problem.

Yes, WebAii supports Win 7 64 bit, that should not be the reason of the problem.

Hope to hear from you soon.

Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Zack
Top achievements
Rank 1
answered on 07 Nov 2013, 05:56 PM
Hi there,

Is there any explanation for this yet?

The mouse click does not work for me either under a specific context.

1) I created a test application in VS 2012 and the mouse click works fine.
2) I added the Telerik Testing Framework into an existing Silverlight app and the mouse click works fine.
3) I added the Telerik Testing Framework into a an existing WPF application which is testing the Silverlight app above and the mouse click does not work. The mouse cursor does not move to the button, it stays where it is. It looks like the security context of the browser initiated by the WPF application is different than the app 1 and 2 above.

I've been trying to figure out what is going on without progress.

Many thanks

0
Andrey Cherepakha
Top achievements
Rank 1
answered on 08 Nov 2013, 12:15 PM
Stephen wrote : "The mouse click does not work for me either under a specific context." The same is for me.

I created a test application from scratch in VS2012 using WebAii 2013.1.911.0 and the mouse click works fine.

But no luck with my main test application, which a bit complicated. I am going to investigate it deeply and get back with a result.
0
Boyan Boev
Telerik team
answered on 08 Nov 2013, 02:05 PM
Hi,

@Andrey, please take your time and update this thread accordingly. 

@Stephen, as I wrote to Andrey, we need to reproduce this locally so we can debug the issue deeper. 

Please check out my post to him.

Hope to hear from you soon.

Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Andrey Cherepakha
Top achievements
Rank 1
answered on 21 Nov 2013, 10:24 AM
After long time investigation I found out that the cause of the issue is NUnit (to be more precise  - which Nunit runner is used to run tests)

Here is my configuration:
Windows 7 64 bit
WebAii 2011.2.1413.0
NUnit 2.5.9.10348

Issue: User.Click() not clicking in Silverlight application if test is defined with TestFixure (NUnit). Everything works fine if test is defined with TestMethod (MS Test).

Solution to make NUnit work:
1) Visual Studio - Solution Explorer - Project Properties - Build - Platform target   change from Any CPU to x86
2) run tests with nunit-x86.exe

To make NUnit tests run from Visual Studio with ReSharper:
1) Visual Studio - ReSharper - Options - Tools - Unit Testing - nUnit - Specified NUnit installation - define path to the NUnit folder with nunit-x86.exe
0
Boyan Boev
Telerik team
answered on 22 Nov 2013, 02:00 PM
Hi Andrey,

Thank you very much for sharing this information.

I have update your Telerik points.

We appreciate your feedback, which we rely on to improve our product. 

Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
angelo
Top achievements
Rank 1
answered on 26 Apr 2019, 02:19 AM
Thank you, this helped me figure out why button is not clicked if I run my test via console while it works fine in Visual Studio
0
Ivaylo
Telerik team
answered on 26 Apr 2019, 04:46 AM
Hello Angelo,

Glad to hear this post has been helpful to you. 

Should you have any additional questions or comments let us know or submit a new thread/ticket.

Regards,
Ivaylo
Progress Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Tim
Top achievements
Rank 2
Answers by
Tim
Top achievements
Rank 2
Daniel
Top achievements
Rank 2
Boyan Boev
Telerik team
Andrey Cherepakha
Top achievements
Rank 1
Zack
Top achievements
Rank 1
angelo
Top achievements
Rank 1
Ivaylo
Telerik team
Share this question
or