HTMLInputControl mouseclick doesn't work

6 posts, 0 answers
  1. Huang
    Huang avatar
    3 posts
    Member since:
    Jul 2013

    Posted 02 Aug 2013 Link to this post

    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();
  2. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 05 Aug 2013 Link to this post

    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
  3. Huang
    Huang avatar
    3 posts
    Member since:
    Jul 2013

    Posted 07 Aug 2013 Link to this post

    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).
  4. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 08 Aug 2013 Link to this post

    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
  5. Navneet
    Navneet avatar
    1 posts
    Member since:
    Nov 2013

    Posted 02 Dec 2013 Link to this post

    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.





           
  6. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 05 Dec 2013 Link to this post

    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
Back to Top