-1
var EC = protractor.ExpectedConditions;
var e = browser.driver.findElement(by.xpath("//img[@class='ngx-loading-logo center-center']"));
browser.wait(EC.presenceOf(e), 7000);

上面的代码给出的错误如下:

 Failures:
1) Actions demo auto search example
 Message:
  Failed: Cannot read property 'presenceOf' of undefined
Stack:
TypeError: Cannot read property 'presenceOf' of undefined
    at UserContext.<anonymous> (D:\old data\personal\work\Automation\Protractor-Angular\Login_FS.js:212:17)
    at C:\Users\AMantri\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:108:15
    at new ManagedPromise (C:\Users\AMantri\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1077:7)
    at ControlFlow.promise (C:\Users\AMantri\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2505:12)
    at schedulerExecute (C:\Users\AMantri\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:95:18)    
    at TaskQueue.execute_ (C:\Users\AMantri\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:3084:14)
    at TaskQueue.executeNext_ (C:\Users\AMantri\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:3067:27)
    at C:\Users\AMantri\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2974:25       
    at C:\Users\AMantri\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:668:7
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
From: Task: Run it("auto search example") in control flow
    at UserContext.<anonymous> (C:\Users\AMantri\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:94:19)
From asynchronous test:
Error
    at Suite.<anonymous> (D:\old data\personal\work\Automation\Protractor-Angular\Login_FS.js:19:5)
    at Object.<anonymous> (D:\old data\personal\work\Automation\Protractor-Angular\Login_FS.js:4:1)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)

Finished in 0.066 seconds

[19:29:51] I/local - Shutting down selenium standalone server.
[19:29:51] I/launcher - 0 instance(s) of WebDriver still running
[19:29:51] I/launcher - chrome #01 failed 1 test(s)
[19:29:51] I/launcher - overall: 1 failed spec(s)
[19:29:51] E/launcher - Process exited with error code 1
4

1 回答 1

0

你可以试试这个吗

const ExpectedConditions = require('protractor').ExpectedConditions;
于 2021-02-24T15:02:20.807 回答