Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20

 

Print

WebDriver select different browsers

see the code below.

 

Code Snippet
  1. public void SetupTest(int browserNumber)
  2.         {
  3.             switch (browserNumber)
  4.             {
  5.                 case 1:
  6.                    _webDriver=new FirefoxDriver();
  7.                     _webDriver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(120));
  8.                     _webDriver.Manage().Cookies.DeleteAllCookies();
  9.                     break;
  10.  
  11.                 case 2:
  12.                      _webDriver=new ChromeDriver();
  13.                     _webDriver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(120));
  14.                     _webDriver.Manage().Cookies.DeleteAllCookies();
  15.                     break;
  16.                 case 3:
  17.                      _webDriver=new InternetExplorerDriver();
  18.                     _webDriver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(120));
  19.                     _webDriver.Manage().Cookies.DeleteAllCookies();
  20.                     break;
  21.                 case 4:
  22.                     _webDriver = new SafariDriver();
  23.                     _webDriver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(120));
  24.                     _webDriver.Manage().Cookies.DeleteAllCookies();
  25.                     break;
  26.  
  27.                 default:
  28.                     _webDriver=new FirefoxDriver();
  29.                     _webDriver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(120));
  30.                     _webDriver.Manage().Cookies.DeleteAllCookies();
  31.                     break;
  32.  
  33.             }
  34.            
  35.             _verificationErrors = new StringBuilder();
  36.         }