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

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

11 Answers 141 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Greg Schnider
Top achievements
Rank 1
Greg Schnider asked on 01 Jun 2010, 05:01 PM
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

11 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 01 Jun 2010, 11:36 PM
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.
0
Greg Schnider
Top achievements
Rank 1
answered on 02 Jun 2010, 08:18 PM
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

0
Accepted
Cody
Telerik team
answered on 04 Jun 2010, 03:58 PM
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.
0
Greg Schnider
Top achievements
Rank 1
answered on 04 Jun 2010, 05:33 PM
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
0
Accepted
Cody
Telerik team
answered on 04 Jun 2010, 05:47 PM
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.
0
Greg Schnider
Top achievements
Rank 1
answered on 04 Jun 2010, 06:13 PM
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
0
Cody
Telerik team
answered on 07 Jun 2010, 08:34 PM
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.
0
Greg Schnider
Top achievements
Rank 1
answered on 29 Jun 2010, 06:55 PM
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
0
Cody
Telerik team
answered on 30 Jun 2010, 06:23 PM
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
0
Greg Schnider
Top achievements
Rank 1
answered on 30 Jun 2010, 09:29 PM
CLICK... setting my build as x86 solved the problem.

Greg
0
Cody
Telerik team
answered on 30 Jun 2010, 11:57 PM
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
Tags
General Discussions
Asked by
Greg Schnider
Top achievements
Rank 1
Answers by
Cody
Telerik team
Greg Schnider
Top achievements
Rank 1
Share this question
or