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

FindStrategy with ChildWindows

0 Answers 53 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 27 Jun 2012, 01:16 PM
Hello,

I'm trying to set the Find Strategy to return null to check if a popup window pops up when a user do a certain action. It works for the Navigating to "http://localhost:1314/MSP/default.aspx#lul" alone, but when I test the btnMap click, I get a null reference exception.

Thanks - Joe

UPDATE: I just caught the exception and work my way around it, no more problems!

[TestMethod()]
public void CheckAllTabs()
{
 
     
    //Elements
    _HyperlinkButton btnMap = myApp.FindName<HyperlinkButton>("btnMap");
 
 
  
    System.Threading.Thread.Sleep(3500);
    btnMap.User.Click();
    System.Threading.Thread.Sleep(3500);
    TestErrorPage();
 
    System.Threading.Thread.Sleep(3500);
    myManager.ActiveBrowser.NavigateTo("http://localhost:1314/MSP/default.aspx#lul");
    System.Threading.Thread.Sleep(3500);
    TestErrorPage();
 
}
 
//Checks for popup error Message
public void TestErrorPage()
{
    FindStrategy originalStrategy = myApp.Popups.FirstOrDefault().VisualTree.Find.Strategy;
    try
    {
        myApp.RefreshVisualTrees();
        System.Threading.Thread.Sleep(3500);
 
        //null reference exception occurs
        myApp.Popups.FirstOrDefault().VisualTree.Find.Strategy = FindStrategy.WhenNotVisibleReturnNull;
 
        Button OKButton = myApp.Popups.FirstOrDefault().VisualTree.Find.ByName<Button>("OKButton");
        Assert.IsNull(OKButton);
    }
 
    finally
    {
        myApp.Popups.FirstOrDefault().VisualTree.Find.Strategy = originalStrategy;
    }
 
}

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
Joe
Top achievements
Rank 1
Share this question
or