Forum Discussion

nastester's avatar
nastester
Regular Contributor
2 years ago

Change browser used in all tests

Is there a way to globally change the browser used in keyword tests rather than having to update each Navigate statement to use a different browser?   
  • eykxas's avatar
    2 years ago

    I don't know what else to tell you.

     

    This is the code (javascript) :

    function startBrowser(){
      var localBrowser;
        
      switch (Project.Variables.browser){
        case "chrome":
        localBrowser = TestedApps.chrome;
        break;
          
        case "msedge":
        localBrowser = TestedApps.msedge;
        break;
          
        default:
        localBrowser = TestedApps.msedge;
      }
     
      localBrowser.Params.SimpleParams.CommandLineParameters = Project.Variables.url;
      localBrowser.Run();
    
      if(!browser.Exists) {
        return false;
      } else {
        return true;
      }
    }


    And I store the value of the browser as a simple string.

     

    In the name mapping I have just this : 


    I make sure only one tested browser is running at a time (otherwise, there may be a conflict).
    And that's it. Anytime I want to call the browser or one of its childs objects I use : Aliases.browser.something.