Forum Discussion

Semirxbih's avatar
Semirxbih
Contributor
11 months ago

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.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    If you re-arrange the code to something like,

    then it will use the current browser, otherwise it will launch a new instance.

    • Semirxbih's avatar
      Semirxbih
      Contributor

      Thanks rraghvani, the problem that I'm having with this is that I don't want it to force to open a new tab. I need it to open the current active browser window and use the existing active tab that is lands on, so that way I can just continue running and executing other steps.

       

      If I open another tab, it will force me to relogin to my program and such and that portion I already figured out in another function, I need it to open the active window if possible, something like this:

      1. Opens Microsoft Edge (Already active).
      2. Oh, we landed on "Smartbear.com", this was the tab that was opened when I maximized the current active browser window.

      3. Let's use "Smartbear.com" and let me continue with my script.

       
       
       
  • Does anyone know what I need to do differently? I can't seem to make it work properly.