Iβve been trying to shut down the ChromeDriver service for some time now, and I cannot develop a solution on how to do this. I use unit test using mocha and tea. The first test passes, and the second because of an error.
I tried looking in the selenium-webdrive / chrome.js module and could not find the function to close the service. I tried to find the answers, but did not find anything on the Internet. Perhaps my approach to creating the chrome driver needs to be redone. I tried to wrap the service creation and setting the default service in an if statement using the selenium-webdriver / chrome.js.getDefaultService () command. IsRunning (), but it did not pass the first test. I am confused by this, and this is most likely due to a lack of knowledge.
This call block is called during each unit test.
var service = new chrome.ServiceBuilder(chromePath).build(); chrome.setDefaultService(service); driver = new webdriver.Builder() .withCapabilities(webdriver.Capabilities.chrome()) .build();
This is the first unit test that passes without errors.
it('Should pass if the Driver is set to equal the Chrome driver by using chrome', function() { var chromeDriver = Driver( { browserName: 'chrome' } ); expect(chromeDriver.getCapabilities().browserName).to.equal('Google Chrome'); });
This is the second unit test, which leads to failure
it('Should pass if the Driver is set to equal the Chrome driver by using google chrome', function() { var chromeDriver = Driver( { browserName: 'google chrome' } ); expect(chromeDriver.getCapabilities().browserName).to.equal('Google Chrome'); });
Error message:
Error: The previously configured ChromeDriver service is still running. You must shut it down before you may adjust its configuration. at Error (native) at Object.setDefaultService (C:\Users\charles.sexton\WebstormProjects\node_modules\selenium-webdriver\chrome.js:346:11) at module.exports (C:\Users\charles.sexton\WebstormProjects\JS-Selenium-Toolkit\src\OrasiDriver.js:90:16) at Context.<anonymous> (C:\Users\charles.sexton\WebstormProjects\JS-Selenium-Toolkit\test\test.js:28:32) at callFn (C:\Users\charles.sexton\WebstormProjects\node_modules\mocha\lib\runnable.js:315:21) at Test.Runnable.run (C:\Users\charles.sexton\WebstormProjects\node_modules\mocha\lib\runnable.js:308:7) at Runner.runTest (C:\Users\charles.sexton\WebstormProjects\node_modules\mocha\lib\runner.js:422:10) at C:\Users\charles.sexton\WebstormProjects\node_modules\mocha\lib\runner.js:533:12 at next (C:\Users\charles.sexton\WebstormProjects\node_modules\mocha\lib\runner.js:342:14) at C:\Users\charles.sexton\WebstormProjects\node_modules\mocha\lib\runner.js:352:7 at next (C:\Users\charles.sexton\WebstormProjects\node_modules\mocha\lib\runner.js:284:14) at Immediate._onImmediate (C:\Users\charles.sexton\WebstormProjects\node_modules\mocha\lib\runner.js:320:5)
source share