Cross browser testing:Click action on UITestcontrol got using ExcuteScript API is not working. RRS feed

  • Question

  • Hi,

    For one of the web control,I am using ExecuteScript API to get the UITestControl as explained in this link (http://blogs.msdn.com/b/visualstudioalm/archive/2013/01/18/introducing-jscript-execution-on-internetexplorer-and-crossbrowser-in-coded-ui-test.aspx )and trying to perform click action on the control.It is not performing the click action on the control but script status is success.

    Problem is seen only with specific Overload of Mouse.Click().Here I am constructing the control using bounding rectangle dynamically.

    The API I am using is

     Microsoft.VisualStudio.TestTools.UITesting.Mouse.Click(UITestControl, MouseButtons.Left, ModifierKey.None, clickablePoint );

    Point Caluculation is shown below:

    clickablePoint  = return new Point(boundingRect.Width / 5, boundingRect.Height / 4);

    I tried to debug the code and found that Selenium web driver is throwing null reference exception while using this API for Left button click action.Could you please check the problem and fix it.So that I can use this API as per my requirement.



    Friday, January 2, 2015 10:12 AM


  • Hi Nagasree,

    Latest version of Chrome and Firefox supported by cross browser testing are Chrome version 38.0.2125.111 and Firefox 33. So please make sure the Chrome and Firefox is supported by cross browser testing

    Whether this API: Microsoft.VisualStudio.TestTools.UITesting.Mouse.Click(UITestControl, MouseButtons.Left, ModifierKey.None, clickablePoint ) worked fine with IE browser when you run this test?

    If the same API worked fine on IE browser but not on Chrome or Firefox browser, “Q AND A” tab in this link: Selenium components for Coded UI Cross Browser Testing is a better place for resolving this problem.

    It seems that you want to click the control using bounding rectangle, then you don't neet to use MouseButtons.Left and ModifierKey.None, you can use such API: Click(UITestControl, Point) or

    Click(Point) directly.

    You also can try to use the following code snippet, maybe it can help you.

    Rectangle r = TargetControl.BoundingRectangle.

    Mouse.Click(new Point(r.X + r.Width/2, r.Y + r.Height/2));


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Edited by Amanda Zhu Monday, January 5, 2015 6:22 AM edit
    • Marked as answer by Amanda Zhu Friday, January 9, 2015 3:10 AM
    Monday, January 5, 2015 6:18 AM