Mouse moving to top left after page load/2nd iteration
Posted: Fri Feb 07, 2014 10:39 pm
Hello.
I am trying to iterate through a web page which has menu bar with options underneath. While initially creating the code I had the mouse pointer move to where I needed it to go (no clicks, just mouse moves) and it worked fine. After changing the code such that the submenu items are clicked, the first iteration works but on the 2nd (and subsequent) iterations the mouse pointer move to the top left of the browser instead of to the menu bar item (which is visible and available). I read another posting about this (http://www.ranorex.com/forum/mouse-move ... t5284.html) and it talked about ensuring that caching is off for the repo items. I confirmed that the root folder in my repository is (and I suppose always was been) set to Use Cache = False.
Any ideas? My code is below in case that helps.
Thanks.
I am trying to iterate through a web page which has menu bar with options underneath. While initially creating the code I had the mouse pointer move to where I needed it to go (no clicks, just mouse moves) and it worked fine. After changing the code such that the submenu items are clicked, the first iteration works but on the 2nd (and subsequent) iterations the mouse pointer move to the top left of the browser instead of to the menu bar item (which is visible and available). I read another posting about this (http://www.ranorex.com/forum/mouse-move ... t5284.html) and it talked about ensuring that caching is off for the repo items. I confirmed that the root folder in my repository is (and I suppose always was been) set to Use Cache = False.
Any ideas? My code is below in case that helps.
Thanks.
Code: Select all
public void NavigateToVisiblePages()
{
Mouse.DefaultMoveTime = 300;
Keyboard.DefaultKeyPressTime = 100;
Delay.SpeedFactor = 1.0;
var mainNav = repo.EnCompass.MenuBarNavigation.MainNav;
IList<Ranorex.SpanTag> myMainMenu = mainNav.Find <Ranorex.SpanTag>(".//div[@class='mainMenuItemNew']/?/?/span");
// Using this for loop instead of ForEach as the elements are in the list backwards
// Uses "i>=1" so that the Help menu, which is indexed 0, isn't included
for (int i = myMainMenu.Count - 1; i >= 1; i--)
{
Ranorex.SpanTag menuitem = myMainMenu[i];
menuitem.MoveTo();
string MainNavName = Regex.Replace(menuitem.ToString(), "SpanTag:", string.Empty);
//Report.Info("menuitem " + menuitem);
//Report.Info("MainNavName " + MainNavName);
//Ranorex.Report.Screenshot (menuitem);
Delay.Milliseconds(200);
//repo.EnCompass.MenuBarNavigation.MainNav.PerformClick();
//Getting drop down items underneath main
var subNav = repo.EnCompass.MenuBarNavigation.SubNavItems;
IList<Ranorex.ATag> mySubMenu = mainNav.Find <Ranorex.ATag>(".//div[@id~'ctl00_MainMenu2_.*']/../div[@class!='mainMenuItemNew' and @visible='True']/*");
Report.Info ("Count : " + mySubMenu.Count.ToString());
foreach (Ranorex.ATag submenuitem in mySubMenu)
{
//submenuitem.MoveTo();
string SubMenuName = Regex.Replace(submenuitem.ToString(), "ATag:", string.Empty);
// Report where we navigated to to the Report
Report.Info(MainNavName + " - " + SubMenuName);
Delay.Milliseconds(200);
// This and the rest worked when the command was MoveTo instead (no page load)
submenuitem.PerformClick();
// Wait for page load
Delay.Seconds(10);
// The menuitem value is still correct
Report.Info("menuitem: " + menuitem);
// When this happens, the cursor moves to the top left instead of the menu item
menuitem.MoveTo();
Delay.Seconds(5);
}
}