gpt4 book ai didi

javascript - Protractor 断言元素不可见

转载 作者:行者123 更新时间:2023-12-01 01:24:54 25 4
gpt4 key购买 nike

我们的网站上有一个隐藏/取消隐藏菜单的图标。我创建了以下脚本来测试它:

 it('Hamburger Menu Click Validation', function () {
expect(Hamburger_Menu.isDisplayed());
Hamburger_Menu.click();
browser.sleep(1000);
expect(foo.isDisplayed()).toBe(false);
Hamburger_Menu.click();
browser.sleep(1000);
expect (foo.isDisplayed().toBe(true));
// expect (invisibilityOf())
})

语句“expect(foo.isDisplayed()).toBe(false);”复制自此website 。我没有看到它失败的任何原因,但是当我运行测试时,我收到以下错误,它表示 :foo.isDisplayed(...).toBe 不是一个函数! 。如何使用 Expect 函数验证菜单是否被隐藏?

estBed Tests Hamburger Menu Click Validation Message: Failed: foo.isDisplayed(...).toBe is not a function Stack: TypeError: foo.isDisplayed(...).toBe is not a function at UserContext. (C:\FCPS_I\FCPS\FCPS\TestBed.js:16:35) at C:\Users\User\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:112:25 at new ManagedPromise (C:\Users\User\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1077:7) at ControlFlow.promise (C:\Users\User\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2505:12) at schedulerExecute (C:\Users\User\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:95:18) at TaskQueue.execute_ (C:\Users\User\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:3084:14) at TaskQueue.executeNext_ (C:\Users\User\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:3067:27) at asyncRun (C:\Users\User\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2927:27) at C:\Users\User\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:668:7 at process._tickCallback (internal/process/next_tick.js:68:7) From: Task: Run it("Hamburger Menu Click Validation") in control flow at UserContext. (C:\Users\User\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:94:19) From asynchronous test: Error at Suite. (C:\FCPS_I\FCPS\FCPS\TestBed.js:9:5) at Object. (C:\FCPS_I\FCPS\FCPS\TestBed.js:1:63) at Module._compile (internal/modules/cjs/loader.js:689:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10) at Module.load (internal/modules/cjs/loader.js:599:32) at tryModuleLoad (internal/modules/cjs/loader.js:538:12)

最佳答案

您只是错误地关闭了括号:

expect(foo.isDisplayed()).toBe(true);

关于javascript - Protractor 断言元素不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53890777/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com