Semirxbih
9 months agoContributor
Opening the current active "EDGE" browser window and using that object instead of closing browser
Hey all,
So I am attempting to save some time by attempting to open the current "EDGE" browser window, and landing on the active tab and just use that object to execute other code, but I am having lots of issues and I can't seem to figure it out.
So currently, this is what I have:
Given("We open the current browser window", function () {
var edgeBrowser = Browsers.Item("EDGE");
// Run the browser which attaches to an existing instance if already open
edgeBrowser.Run();
// Get the current browser window
var browserWindow = Sys.Browser("EDGE").BrowserWindow(0);
if (browserWindow.Exists) {
// Activate and then maximize the browser window
browserWindow.Activate();
browserWindow.Maximize();
Log.Message("Microsoft Edge window has been activated and maximized.");
} else {
Log.Warning("Unable to find the Microsoft Edge window.");
}
});
Outputting "Browsers.Item("EDGE")", I can see that Microsoft Edge is detectable:
I can also see that I do have an active "EDGE" object:
For some reason, when I execute that code, it opens up a new "Internet Explorer" window and I don't want that, I just want it to open the current active browser and use the active tab that it lands on.
If you re-arrange the code to something like,
then it will use the current browser, otherwise it will launch a new instance.