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

HTMLInputControl mouseclick doesn't work

5 Answers 34 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Huang
Top achievements
Rank 1
Huang asked on 02 Aug 2013, 11:48 AM
Hi,
I am using the mouseclick to click a button. However, the mouse cannot move to the top of the button. I also tried the Actions.click, mouse left click, mouse leftdoubleclick, none of them can work. But If I click the button manually, this button can work well and the dialog can be closed successfully. See my code and screenshot. Actually, this issue doesn't happen with mouse click for other buttons.

HtmlFindExpression htmlFindExpress = new HtmlFindExpression("id=popup_panel");
ActiveBrowser.WaitForElement(htmlFindExpress, 5000, false);
Find.ById<HtmlInputButton>("popup_ok").MouseClick();

5 Answers, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 05 Aug 2013, 10:27 AM
Hello Huang,

Thank you for contacting us. 

Could you try out this slightly modified code:

HtmlDiv myDiv = ActiveBrowser.Find.ById<HtmlDiv>("id=popup_panel");
HtmlFindExpression htmlFindExpress = new HtmlFindExpression("id=popup_panel");
ActiveBrowser.WaitForElement(htmlFindExpress, 5000, false);
ActiveBrowser.RefreshDomTree();
myDiv.Find.ById<HtmlInputButton>("popup_ok").MouseClick();

Let me know if this helps.

Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Huang
Top achievements
Rank 1
answered on 07 Aug 2013, 10:51 AM
Hi Boyan,

Thanks for your feedback. However, this code cannot resolve my issue. I got an Object reference not set to an instance of an object error when running MouseClick().

I am using the following code as workaround.
ActiveBrowser.Windows.SetFocus()
Find.ById<HTMLInputButton>("popup_ok").MouseClick();

But this workaround is not stable either. The MouseClick will fail sometimes (nearly 1/5 failed).
0
Boyan Boev
Telerik team
answered on 08 Aug 2013, 01:58 PM
Hello Huang,

That means that the DOM tree is not fully loaded when you are trying to click on the element.

There are several options you can try.

1. Add a wait statement for the element you are clicking on.

2. Sleep the thread for 2 seconds for example: 

System.Threading.Thread.Sleep(2000);

If the issue persists please 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. If it is not possible to grant us access to your application, please take a Fiddler trace and attach it to a support ticket in a zip file. You can capture a Fiddler trace using FiddlerCap.


Hope to hear from you soon.

Hope this helps.

Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Navneet
Top achievements
Rank 1
answered on 02 Dec 2013, 01:20 PM
hello Boyan,
 I have the same issue as faced by Huang ( Object reference not set as reference of object ).  i want to click on a button ie.. in input but its not clicking.


a id="ctl00_ContentPlaceHolderSubMenu_btnLogin" class="RadButton RadButton_Metro rbSkinnedButton" href="javascript:void(0)">

<input id="ctl00_ContentPlaceHolderSubMenu_btnLogin_input" class="rbDecorated" type="button" value="Log In" name="ctl00$ContentPlaceHolderSubMenu$btnLogin_input" tabindex="-1">



       
0
Boyan Boev
Telerik team
answered on 05 Dec 2013, 10:54 AM
Hello Navneet,

Thank you for contacting us.

Did you try out the suggestions in my last responses?

If the issue persists please us the trace log so we can investigate the issue further.

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
Tags
General Discussions
Asked by
Huang
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Huang
Top achievements
Rank 1
Navneet
Top achievements
Rank 1
Share this question
or