diff --git a/lib/helper/SeleniumWebdriver.js b/lib/helper/SeleniumWebdriver.js index 6c799702b..6d62c9dbf 100644 --- a/lib/helper/SeleniumWebdriver.js +++ b/lib/helper/SeleniumWebdriver.js @@ -148,9 +148,8 @@ class SeleniumWebdriver extends Helper { if (this.options.keepCookies) return; // if browser should not be restarted this.debugSection('Session', 'cleaning cookies and localStorage'); - return this.browser.executeScript('localStorage.clear();').then(() => { - return this.browser.manage().deleteAllCookies(); - }); + this.browser.manage().deleteAllCookies(); + return this.browser.executeScript('localStorage.clear();'); } _afterSuite() { diff --git a/lib/helper/WebDriverIO.js b/lib/helper/WebDriverIO.js index 0a7b5cd40..1a0808cf8 100644 --- a/lib/helper/WebDriverIO.js +++ b/lib/helper/WebDriverIO.js @@ -288,9 +288,8 @@ class WebDriverIO extends Helper { if (this.options.restart) return this.browser.end(); if (this.options.keepCookies) return; this.debugSection('Session', 'cleaning cookies and localStorage'); - return this.browser.execute('localStorage.clear();').then(() => { - return this.browser.deleteCookie(); - }); + this.browser.deleteCookie(); + return this.browser.execute('localStorage.clear();'); } _afterSuite() { @@ -778,7 +777,7 @@ class WebDriverIO extends Helper { seeNumberOfVisibleElements(selector, num) { return this.browser.isVisible(withStrictLocator(selector)) .then(function (res) { - if(!Array.isArray(res)) res = [res]; + if (!Array.isArray(res)) res = [res]; res = res.filter((val) => val == true); return truth(`elements of ${locator}`, 'to be seen').assert.equal(res.length, num); }); @@ -1268,14 +1267,14 @@ function withStrictLocator(locator) { locator.toString = () => `{${key}: '${value}'}`; switch (key) { - case 'by': - case 'xpath': - case 'css': - return value; - case 'id': - return '#' + value; - case 'name': - return `[name="${value}"]`; + case 'by': + case 'xpath': + case 'css': + return value; + case 'id': + return '#' + value; + case 'name': + return `[name="${value}"]`; } }