I am stuck badly with this piece of code. I am trying to write a code to use existing Browser if it exists otherwise launch my website in new browser window. Currently, if browser is not open with title "mysite" it throw an exception and doesn't go into else {} block where I'm expecting it to launch mysite instead of getting failed.
[TestInitialize]
public void Initialize()
{
if (BrowserWindow.Locate("mysite").Exists)
{
BrowserWindow.CurrentBrowser = "ie";
mParentWindow = BrowserWindow.Locate("odrive");
mParentWindow.Maximized = !mParentWindow.Maximized;
}
else
{
BrowserWindow.CurrentBrowser = "ie";
mParentWindow = BrowserWindow.Launch("www.mysite.com");
mParentWindow.CloseOnPlaybackCleanup = false;
mParentWindow.Maximized = !mParentWindow.Maximized;
}
}