C# - Watin - Ajax Based DropDown Menu - Whooping my butt.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: C# - Watin - Ajax Based DropDown Menu - Whooping my butt.

  1. #1
    Join Date
    Dec 2011
    Posts
    3

    Question C# - Watin - Ajax Based DropDown Menu - Whooping my butt.

    Hello,

    I've maxed out my capabilities in trying to find of a solution for causing/toggling a menu item to expand. I'm using watin currently and can solve most problems with it, but not this one. There is some trick involved in getting the menu item to toggle open and I am unable to solve it. What's funny is UBot can successfully toggle the menu item using an OuterHTML search, so I'm fairly certain that mouse corrdinate inputs are not required.

    I need to attempt to do this without forcing mouse coordinates because this software will eventually become commercial software designed to run in the background of the user's computer.

    Here are some examples of code I've been using to try and force the menu to click.

    PHP Code:
                                             watin.Div div =ie.Div(watin.Find.ByClass("classnamehere1"));
                                            
    div.MouseEnter();
                                            
                                            
    f_sleep(5);
                                            
    div.FireEvent("onmouseover");
                                            
    div.FireEvent("onmouseover");
                                            
    div.FireEvent("onmouseover");
                                            
    div.FireEvent("onmouseover");
                                            
    div.FireEvent("onmouseover");
                                            
    div.FireEvent("onmousemove");
                                            
    div.FireEvent("onmousemove");
                                            
    div.FireEvent("onmousemove");
                                            
    div.FireEvent("onmousemove");
                                            
    div.FireEvent("onmousemove");
                                            
    div.FireEvent("onmouseover");
                                            
    div.ClickNoWait();
                                            
    div.FireEvent("onmousedown");     
                                            
    div.ClickNoWait();                                        
                                            
    div.Click();
                                            
    div.MouseEnter();
                                            
    f_sleep(5);
                                            
                                            
    watin.Span span =ie.Span(watin.Find.ByClass("classnamehere2"));
                                            
                                            
    span.FireEvent("onmouseover");
                                            
    span.FireEvent("onmouseover");
                                            
    span.FireEvent("onmouseover");
                                            
    span.FireEvent("onmouseover");
                                            
    span.FireEvent("onmouseover");
                                            
    span.FireEvent("onmousemove");
                                            
    span.FireEvent("onmousemove");
                                            
    span.FireEvent("onmousemove");
                                            
    span.FireEvent("onmousemove");
                                            
    span.FireEvent("onmousemove");
                                            
    span.MouseEnter();
                                            
    span.FireEvent("onmouseover");
                                            
    span.ClickNoWait();
                                            
    span.FireEvent("onmousedown");                                     
                                            
    span.ClickNoWait();
                                            
    div.MouseEnter();
                                            
    f_sleep(5);
                                            
                                            
    span.Parent.MouseEnter();
                                            
    span.Parent.MouseEnter();
                                            
    span.Parent.MouseEnter();
                                            
    span.Parent.FireEvent("onmouseover");
                                            
    span.Parent.FireEvent("onmouseover");
                                            
    span.Parent.FireEvent("onmouseover");
                                            
    span.Parent.FireEvent("onmouseover");
                                            
    span.Parent.FireEvent("onmouseover");
                                            
    span.Parent.FireEvent("onmousemove");
                                            
    span.Parent.FireEvent("onmousemove");
                                            
    span.Parent.FireEvent("onmousemove");
                                            
    span.Parent.FireEvent("onmousemove");
                                            
    span.Parent.FireEvent("onmousemove");
                                            
    span.Parent.ClickNoWait();
                                            
    span.Parent.FireEvent("onmousedown");                                     
                                            
    span.Parent.ClickNoWait();
                                            
    div.Parent.MouseEnter();
                                            
    f_sleep(5);

                                            
                                            var 
    searchResults = (watin.IElementContainer)ie.Element(watin.Find.ByClass("classnamehere"));

                                            foreach (
    watin.Element element in searchResults.Elements) {
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter");                                             
                                                
    element.FireEvent("onmousedown"); 
                                                
    element.FireEvent("onmousedown"); 
                                                
    element.FireEvent("onmousedown"); 
                                                
    element.FireEvent("onmousedown"); 
                                                
    element.FireEvent("onmousedown"); 
                                                
    element.FireEvent("onmouseover"); 
                                                
    element.FireEvent("onmouseover"); 
                                                
    element.FireEvent("onmouseover"); 
                                                
    element.FireEvent("onmouseover"); 
                                                
    element.FireEvent("onmouseover"); 
                                                
    element.FireEvent("onchange");
                                                
    element.FireEvent("onchange");
                                                
    element.FireEvent("onchange");
                                                
    element.FireEvent("onchange");
                                                
    element.FireEvent("onchange");
                                                
    element.FireEvent("onchange");
                                                
    element.FireEvent("onchange");
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.DoubleClick();
                                                
    element.DoubleClick();
                                                
    element.DoubleClick();
                                                
    element.DoubleClick();
                                                
    element.DoubleClick();
                                                
    element.DoubleClick();
                                                
    element.DoubleClick();
                                                
    element.DoubleClick();
                                                
    element.DoubleClick();
                                                
    element.ClickNoWait();
                                                
    element.ClickNoWait();
                                                
    element.ClickNoWait();
                                                
    element.ClickNoWait();
                                                
    element.ClickNoWait();
                                                
    element.ClickNoWait();
                                                
    element.ClickNoWait();
                                                
    element.ClickNoWait();
                                                
    element.ClickNoWait();
                                                
    element.ClickNoWait();

                                                var 
    searchResults2 = (watin.IElementContainer)element;
                                                foreach (
    watin.Element element2 in searchResults2.Elements
                                                {    
                                                    
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.MouseEnter();
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmouseover");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmousemove");
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter"); 
                                                
    element.FireEvent("onmouseenter");                                             
                                                
    element.FireEvent("onmousedown"); 
                                                
    element.FireEvent("onmousedown"); 
                                                
    element.FireEvent("onmousedown"); 
                                                
    element.FireEvent("onmousedown"); 
                                                
    element.FireEvent("onmousedown"); 
                                                
    element.FireEvent("onmouseover"); 
                                                
    element.FireEvent("onmouseover"); 
                                                
    element.FireEvent("onmouseover"); 
                                                
    element.FireEvent("onmouseover"); 
                                                
    element.FireEvent("onmouseover"); 
                                                
    element.FireEvent("onchange");
                                                
    element.FireEvent("onchange");
                                                
    element.FireEvent("onchange");
                                                
    element.FireEvent("onchange");
                                                
    element.FireEvent("onchange");
                                                
    element.FireEvent("onchange");
                                                
    element.FireEvent("onchange");
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.Click();
                                                
    element.DoubleClick();
                                                
    element.DoubleClick();
                                                
    element.DoubleClick();
                                                
    element.DoubleClick();
                                                
    element.DoubleClick();
                                                
    element.DoubleClick();
                                                
    element.DoubleClick();
                                                
    element.DoubleClick();
                                                
    element.DoubleClick();
                                                
    element.ClickNoWait();
                                                
    element.ClickNoWait();
                                                
    element.ClickNoWait();
                                                
    element.ClickNoWait();
                                                
    element.ClickNoWait();
                                                
    element.ClickNoWait();
                                                
    element.ClickNoWait();
                                                
    element.ClickNoWait();
                                                
    element.ClickNoWait();
                                                
    element.ClickNoWait();
                                                }
                                            }
                                            
                                            
                                            
                                            
    count++;
                                        } 
    With this code I can highlight the button, but no menu drops down as when my mouse rolls over the menu.

    Is there anything else I can be trying?
    Last edited by adbox; December 22nd, 2011 at 04:27 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center