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!
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;
}
}