Forum Discussion

efuller's avatar
efuller
Occasional Contributor
8 years ago

Browser Loop issue

Hello Everyone, 

 

What I'm trying to do is separate certain functions into Unit Tests and then combine them into a new test as an Integration test.

 

As an example, here is what I'll be doing:

 

Test 1 "Sign Into Gmail": starting FireFox, navigate to gmail, sign in.

Test 2 "Sign Out of Gmail": Click the SignOut button, verify you are logged out

 

That would mean the Integration test would be:

Sign Into Gmail 

Sign Out of Gmail.

 

My problem, is when I'm creating a browser loop in the Integration test, it starts off on the right foot and will open the the first browser, but because I used FireFox for my unit testing, FireFox will be prematurely launched and the test will fail.

 

Does anyone have a solution to this?

 

  • It would be helpful to see the code/screenshot of the keyword test for the sign in portion.  Basically, when you write a browser action like launching a browser, you have an option to specify either to use a specific browser or to use the brower from within the loop.

     

    Basically, in Test1, remove the part about starting FireFox.  The BrowserLoop operation in Keyword Tests (if that's what you're using) automatically launches the browser so, in subsequent tests and test steps, you don't need to actually launch the browser.

     

    If you're not using Keyword tests, the methodology is still the same.... you use a generic "browser" call to launch the browser and, in your subsequent calls, simply reference "Aliases.browser" or however you're referencing the browser as in this sample code from the help:


    function IterateBrowsers1()
    {
      for (let browser of Browsers)
      {
        // Start a browser instance
        browser.Run();
        // Perform web testing
        // ...
        // Close the browser instance
        Aliases.browser.Close();
        
      }
    }

    OR

     

     

    function IterateBrowsers2()
    {
      for (var i = 0; i < Browsers.Count; i++)
      {
        browser = Browsers.Item(i);
        // Start a browser instance
        browser.Run();
        // Perform web testing
        // ...
        // Close the browser instance
        Aliases.browser.Close();
      }
    }

     

     

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    It would be helpful to see the code/screenshot of the keyword test for the sign in portion.  Basically, when you write a browser action like launching a browser, you have an option to specify either to use a specific browser or to use the brower from within the loop.

     

    Basically, in Test1, remove the part about starting FireFox.  The BrowserLoop operation in Keyword Tests (if that's what you're using) automatically launches the browser so, in subsequent tests and test steps, you don't need to actually launch the browser.

     

    If you're not using Keyword tests, the methodology is still the same.... you use a generic "browser" call to launch the browser and, in your subsequent calls, simply reference "Aliases.browser" or however you're referencing the browser as in this sample code from the help:


    function IterateBrowsers1()
    {
      for (let browser of Browsers)
      {
        // Start a browser instance
        browser.Run();
        // Perform web testing
        // ...
        // Close the browser instance
        Aliases.browser.Close();
        
      }
    }

    OR

     

     

    function IterateBrowsers2()
    {
      for (var i = 0; i < Browsers.Count; i++)
      {
        browser = Browsers.Item(i);
        // Start a browser instance
        browser.Run();
        // Perform web testing
        // ...
        // Close the browser instance
        Aliases.browser.Close();
      }
    }