CodeceptJS run java script code

Ingo Foerster
Ingo Foerster used Ask the Experts™
on
Anybody here who can give me a hint to execute custom Javascript inside a CodeceptJS script?
I need to close a layered window and I currently cannot do it with codeceptJS default calls, so I want to close it with jQuery.
I use
	I.executeScript(function() {
		$('#Sidemenu').hide();
	});

Open in new window

Inside my test, but I only get the error message that $ is not defined.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Front-end Developer
Commented:
Hello Ingo,

Did you import the JQuery scripts in your <head></head>

As per Jquery's website the script should be:
<script
  src="https://code.jquery.com/jquery-3.4.1.js"
  integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
  crossorigin="anonymous"></script>

Open in new window

Ingo FoersterProject Leader

Author

Commented:
Many thanks for the quick help

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial