Able to identify objects, but cannot move mouse pointer to them

12 posts, 2 answers
  1. Greg Schnider
    Greg Schnider avatar
    10 posts
    Member since:
    Apr 2010

    Posted 01 Jun 2010 Link to this post

    I am having a rather frustrating issue in that I am able to identify objects within my web page, and do actions on them (eg. .Click() or setting text value for an HtmInputText element), but am completely unable to do any mouse actions on them (eg, .ScrollToVisible(), .MouseHover(), .MouseClick()). The mouse pointer does not move at all.

    I am running my tests on a W7 box with VS2008 using IE8.

    Any suggestions would be appreciated.

    Greg
  2. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 01 Jun 2010 Link to this post

    Hi Greg Schnider,

    Are you using one of our templates? Are you using code similar to this?

    Manager.Desktop.Mouse.Click(MouseClickType.LeftClick, Pages.AfricaBing.AfricaStrongTag.GetRectangle());

    Post a couple of code samples and we'll try to figure out why the code is not working for you.

    Best wishes,
    Cody
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Greg Schnider
    Greg Schnider avatar
    10 posts
    Member since:
    Apr 2010

    Posted 02 Jun 2010 Link to this post

    Thank you for your response.

    The relevent bits of code are:
    Settings MySettings = new Settings(BrowserType.InternetExplorer, @"C:\log\");  
    Manager MyManager = new Manager(MySettings);  
    MyManager.Start();  
    MyManager.LaunchNewBrowser();  
    MyManager.ActiveBrowser.NavigateTo(ProjectVariables.ServerURL);  
     
    MyManager.ActiveBrowser.WaitUntilReady();  
    MyManager.ActiveBrowser.RefreshDomTree();  
     
    HtmlInputText UserElement = MyManager.ActiveBrowser.Find.ById<HtmlInputText>("<some string here>");  
     
    UserElement.ScrollToVisible();  
    UserElement.MouseHover();  
    UserElement.MouseClick();  
    Manager.Current.Desktop.KeyBoard.TypeText("<some string here>", 50); 

    I am able to identify the HtmlInputText element sucessfully, but the .ScrollToVisible, .MouseHover and .MouseClick do nothing. The mouse doesn't move at all. It's as if the browser isn't in focus within the web browser. If is use:

     

    UserElement.Text = "<some string here>"

    then I am able to set the value of the element and the new value appears in the web page. So I definitely have control of the element.

     

    I am not using the unit test infrastructure, but rather just the WebAii libraries for element identification and manipulation. Is there some other intialization that I need to be doing?

    Greg

  4. Answer
    Cody
    Admin
    Cody avatar
    3354 posts

    Posted 04 Jun 2010 Link to this post

    Hi Greg Schnider,

    I did some experimentation using this code:

    [TestMethod]
    public void TestMethod1()
    {
        Settings MySettings = new Settings(BrowserType.InternetExplorer, @"C:\log\");
        Manager MyManager = new Manager(MySettings);
        MyManager.Start();
        MyManager.LaunchNewBrowser();
        MyManager.ActiveBrowser.NavigateTo("http://www.bing.com");
        //MyManager.ActiveBrowser.WaitUntilReady();
        //MyManager.ActiveBrowser.RefreshDomTree();
        HtmlInputText UserElement = MyManager.ActiveBrowser.Find.ById<HtmlInputText>("sb_form_q");
        UserElement.ScrollToVisible();
        UserElement.MouseHover();
        UserElement.MouseClick();
        Manager.Current.Desktop.KeyBoard.TypeText("<some string here>", 50);  
    }

    What I found is that everything works as expected as long as I don't set a breakpoint after the NavigateTo call. If I set a breakpoint at MouseHover (for example), then when the breakpoint is hit, input focus is automatically taken away from the browser by Windows and given to Visual Studio so you can interact with Visual Studio. This makes everything break in the code after the breakpoint. You would have to add code to give focus back to the IE browser window after the breakpoint for it to start to work properly again.

    Also, from your code sample, the WaitUntilReady and RefreshDomTree are redundant. The NavigateTo step does this automatically.

    Greetings,
    Cody
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Greg Schnider
    Greg Schnider avatar
    10 posts
    Member since:
    Apr 2010

    Posted 04 Jun 2010 Link to this post

    Cody,

    Thank you for your response. You mentioned that:

    <quote>
    You would have to add code to give focus back to the IE browser window after the breakpoint for it to start to work properly again.
    </quote>

    How would one do this?

    Greg
  6. Answer
    Cody
    Admin
    Cody avatar
    3354 posts

    Posted 04 Jun 2010 Link to this post

    Hello Greg Schnider,

    [TestMethod]
    public void TestMethod1()
    {
        Settings MySettings = new Settings(BrowserType.InternetExplorer, @"C:\log\");
        Manager MyManager = new Manager(MySettings);
        MyManager.Start();
        MyManager.LaunchNewBrowser();
        MyManager.ActiveBrowser.NavigateTo("http://www.bing.com");
        //MyManager.ActiveBrowser.WaitUntilReady();
        //MyManager.ActiveBrowser.RefreshDomTree();
        HtmlInputText UserElement = MyManager.ActiveBrowser.Find.ById<HtmlInputText>("sb_form_q");
        UserElement.ScrollToVisible();
        MyManager.ActiveBrowser.Window.SetFocus();
        UserElement.MouseHover();
        UserElement.MouseClick();
        Manager.Current.Desktop.KeyBoard.TypeText("<some string here>", 50);  
    }

    Set your breakpoint on the SetFocus call. Then when you tell VS to resume execution, the browser window will immediately get focus back and the rest of the test can run as if nothing happened.

    Regards,
    Cody
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. Greg Schnider
    Greg Schnider avatar
    10 posts
    Member since:
    Apr 2010

    Posted 04 Jun 2010 Link to this post

    Thank you for your speedy response. I am still not having any joy though :(

    I can get the functionality to work if I place it within a unit test context, however if I just use the WebAii functionality as a standalone API, I am able to identify and manipulate the web page elements, but I have no mouse control within the web page. Is there some additional setup/configuration I would need to do in this case? Is this even supported by WebAii?

    Thanks,

    Greg
  8. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 07 Jun 2010 Link to this post

    Hi Greg Schnider,

    Yes using the framework in an application is supported and works fine. I've attached a sample console application to demonstrate.

    Best wishes,
    Cody
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  9. Greg Schnider
    Greg Schnider avatar
    10 posts
    Member since:
    Apr 2010

    Posted 29 Jun 2010 Link to this post

    I am suspecting that the issue I am having may be OS related. I am doing the development on a W7 machine, where the mouse pointer is NOT moving. When I copy the my executable to a W2003 machine, the mouse moves as expected.

    Greg
  10. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 30 Jun 2010 Link to this post

    Hello Greg Schnider,

    I am glad to hear you are homing in on the problem. Something else to watch out for (may not be a problem in your case)... if you are developing on a 64bit machine the default project setting is for "Any CPU". That means it'll run as a 64bit app on a 64 bit machine and as a 32bit app on a 32bit machine and you'll get strange results. You have to explicitly set your configuration to build for x86 only.

    Kind regards,
    Cody
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Greg Schnider
    Greg Schnider avatar
    10 posts
    Member since:
    Apr 2010

    Posted 30 Jun 2010 Link to this post

    CLICK... setting my build as x86 solved the problem.

    Greg
  12. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 30 Jun 2010 Link to this post

    Hi Greg Schnider,

    Fantastic! Glad it was that simple and that I could help. Have a good day!

    Sincerely yours,
    Cody
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top