On our site there is an icon that hides/unhides the menu. I created the following script to test it :
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())
})
The statement "expect(foo.isDisplayed()).toBe(false);" is copied from this website. I do not see any reason for its failure, but when I run the test I get the following error, which says that :foo.isDisplayed(...).toBe is not a function!! . How can I validate if the menu gets hidden using expect function?
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)