1- const { By, Key, until, Builder, Select } = require ( 'selenium-webdriver' )
1+ const { By, Key, until, Builder, Select, WebDriverError , NoSuchSessionError } = require ( 'selenium-webdriver' )
22
33const MENU_TABS = By . css ( 'div#menu ul#tabs' )
44const USER = By . css ( 'li#logout' )
@@ -185,7 +185,9 @@ module.exports = class BasePage {
185185 'Timed out after [timeout=' + this . timeout + ';polling=' + this . polling + '] seconds locating ' + locator ,
186186 this . polling )
187187 } catch ( error ) {
188- console . error ( "Failed to locate element " + locator )
188+ if ( ! error . name . includes ( "NoSuchSessionError" ) ) {
189+ console . error ( "Failed waitForLocated " + locator + " due to " + error )
190+ }
189191 throw error
190192 }
191193 }
@@ -195,8 +197,10 @@ module.exports = class BasePage {
195197 return this . driver . wait ( until . elementIsVisible ( element ) , this . timeout ,
196198 'Timed out after [timeout=' + this . timeout + ';polling=' + this . polling + '] awaiting till visible ' + element ,
197199 this . polling )
198- } catch ( error ) {
199- console . error ( "Failed to find visible element " + element )
200+ } catch ( error ) {
201+ if ( ! error . name . includes ( "NoSuchSessionError" ) ) {
202+ console . error ( "Failed to find visible element " + element + " due to " + error )
203+ }
200204 throw error
201205 }
202206 }
@@ -207,7 +211,9 @@ module.exports = class BasePage {
207211 try {
208212 return this . waitForVisible ( await this . waitForLocated ( locator ) )
209213 } catch ( error ) {
210- console . error ( "Failed to waitForDisplayed for locator " + locator )
214+ if ( ! error . name . includes ( "NoSuchSessionError" ) ) {
215+ console . error ( "Failed to waitForDisplayed " + locator + " due to " + error )
216+ }
211217 throw error
212218 }
213219 }
0 commit comments