mardi 21 février 2017

Timeout not reflect for ElementFinder: (xpath, css)

Team, I have a function, which needs to locate the element, `

    var EC = protractor.ExpectedConditions;
    var busyLoaderEC = EC.stalenessOf(busyLoaderElement);
    var eleClickPresenceEC = EC.presenceOf(eleClickObject);
    var eleClickableEC = EC.elementToBeClickable(eleClickObject);

    var deferred = Q.defer();

    try {
        browser.wait(EC.and(busyLoaderEC, eleClickPresenceEC, eleClickableEC),
            config.timeout, constants.errorMessages.conditionTimedOut).then(function () {

                browser.sleep(1000); //Force Delay                    
                commonHelper.highlightElement(eleClickObject);



            }, function (error) {
                commonHelper.writeLog("ClickObject: " + error);
                deferred.reject(["ClickObject: " + error, reportFiller]);
            });
    }
    catch (error) {
        deferred.reject(["ClickObject: Element Not found -" + error, reportFiller]);
    }

`

When there element is an id and it expected to be not found, it will wait for the

config.timeout

finished then return an error with the error message as I defined in

constants.errorMessages.conditionTimedOut

But for CSS, or xpath locator, if this element could not be found, there is no timeout, it will immediately throw following error:

CT-Driver Automation Suite Iteration Message: Failed: No element found using locator: By(xpath, //div[@wj-part='root']//div[@wj-part='cells']//div[4]//span) Stack: NoSuchElementError: No element found using locator: By(xpath, //div[@wj-part='root']//div[@wj-part='cells']//div[4]//span) at WebDriverError (c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:27:10) at NoSuchElementError (c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:242:10) at c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\built\element.js:699:27 at ManagedPromise.invokeCallback_ (c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1379:14) at TaskQueue.execute_ (c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2913:14) at TaskQueue.executeNext_ (c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2896:21) at c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2775:27 at c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:639:7 at process._tickCallback (node.js:369:9) From: Task: WebDriver.executeScript() at Driver.schedule (c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:377:17) at Driver.executeScript (c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:526:16) at Browser.to.(anonymous function) [as executeScript] (c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\built\browser.js:60:29) at Object.highlightElement (c:\Users*\Documents\projects*\ct-driver\common\commonHelper.js:409:24) at c:\Users*\Documents\projects*\ct-driver\services\seleniumService.js:82:34 at ManagedPromise.invokeCallback_ (c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1379:14) at TaskQueue.execute_ (c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2913:14) at TaskQueue.executeNext_ (c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2896:21) at c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2775:27 at c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:639:7 From: Task: Run it("Suite Iteration") in control flow at Object. (c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\jasminewd2\index.js:81:14) at c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\jasminewd2\index.js:18:5 at ManagedPromise.invokeCallback_ (c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1379:14) at TaskQueue.execute_ (c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2913:14) at TaskQueue.executeNext_ (c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2896:21) at c:\Users*\Documents\projects*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2775:27 From asynchronous test: Error at Suite. (c:\Users*\Documents\projects*\ct-driver\app.js:111:3) at Object. (c:\Users*\Documents\projects*\ct-driver\app.js:65:1) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12)

This is annoying since I want my testing case continue even it encountered the "element_not_found" error.

Could you help me regarding this?

Thank you very much!

Aucun commentaire:

Enregistrer un commentaire