Reputation: 31
How can I terminate driver instance without throwing an exception? Sometimes it quits before anything is done.
driver.get('http://www.google.com');
var query = driver.wait(until.elementLocated(By.name("q")));
query.sendKeys('webdriver\n');
driver.wait(until.titleIs('webdriver - Google Search'));
driver.quit();
Upvotes: 0
Views: 1901
Reputation: 11
Those methods return promises. So you need to wait for them to execute those operations in order. For example
await driver.get('http://www.google.com');
See https://github.com/SeleniumHQ/selenium/tree/master/javascript/node/selenium-webdriver#usage for more details
Upvotes: 1
Reputation: 177
you can also try the following function and call that function in your script
public void tearDown()
{
if(driver!=null)
{
driver.quit();
}
}`
Upvotes: 0