1

Before I run my TestNG suite I would like to check that Chrome and Edge webdriver are up to date and stop the TestNG suite if the browser can't be lauched.

My code so far is,

    EdgeDriver driver2 = new EdgeDriver();
    StartBrowser.driver(driver2, prop2);
    LogFile.logfile("Perform Second logon to Edge Browser");

    if(!LogonUser.logonButton(driver2).isEnabled())
    {
        LogFile.logfile("Logon button not detected for Edge, assuming webdriver is out of date");
        System.exit(2);
    }

    LogFile.logfile("Logon button detected, webdriver is assumed to be valid for Edge");

At the point this line, "EdgeDriver driver2 = new EdgeDriver();" runs, it goes into the TestInvoker.class and the test stops and goes on to the next @test.

Is there a way of testing the webdriver before instantiating it?

Or perhaps I'm looking at the solution in the wrong way?

Many Thanks.

Prophet
  • 32,350
  • 22
  • 54
  • 79
Ian Thompson
  • 187
  • 1
  • 11

1 Answers1

1

You can use WebDriverManager.
This will insure your WebDriver is always updated automatically.

Prophet
  • 32,350
  • 22
  • 54
  • 79
  • Thank you, this is so much easier. For reference this site, https://www.toolsqa.com/selenium-webdriver/webdrivermanager/, helped me to add the external jar files, then use the "import io.github.bonigarcia.wdm.WebDriverManager;" to reference WebDriverManager to call "WebDriverManager.edgedriver().setup();", which updates the webdriver for me. No more checking browser version and getting the correct webdriver and downloading etc. – Ian Thompson Sep 21 '22 at 13:08