Closed monika-pietrosian closed 2 years ago
Hi @monika-pietrosian thanks for taking the time to write a so detailed bug description that helps a lot!
In your first script change:
User.loginWithPerformanceAccount();
to return User.loginWithPerformanceAccount();
(return a promise that will be a success when the navigation finish) or if you will run some other commands after that use await User.loginWithPerformanceAccount();
.
What happens without that is that that function runs and sitespeed.io do not understand to wait on it to finish before continuing so it closes the connection to the browser.
The await is only needed when the function returns a promise and we want to wait on to finish before we move on with the next thing.
Hope that helps!
Ouuu yes, it helped a lot :). I wouldn't call it a bug anymore then, but if someone else would struggle with it maybe they can find it here in the closed issues :). Thank you!
I'm gonna update the documentation so we have a section explaining when to use awaity/return etc.
Have you read the documentation?
URL
www.google.com
What are you trying to accomplish
When trying to run a function that is imported from a separate file, there is an error while using the methods that are imitating the browser,
like context.selenium.driver.get('https://www.google.com')
orcommands.navigate('https://www.google.com')
;. Other commands, likecontext.log.info
orcommands.wait.byTime
get recognized and don't cause error. In both of the cases, session doesn't get initiated.Since this option is mentioned in the documentation I assume it should be possible: https://www.sitespeed.io/documentation/sitespeed.io/scripting/#reuse-scripts
Exact how you run (the exact parameters):
docker run --rm -v "$(pwd):/sitespeed.io" sitespeedio/sitespeed.io:24.7.0 exampleScript.js --multi -n 1
Which version you are using: 24.7.0 OS (if you use Docker, report the base OS): Windows 10 Pro 21H1 Browser version (if you don't run Docker): N/A - use dockerIt works as expected better when the function is not inside a class, I included scripts to reproduce that case as well. It might be also my mistake in this case please change it from a bug into a question and guide me a bit if the time allows :).
first file - exampleScript.js
second file - exporttrial.js
Now for the variant without classes - command stays the same
first file without class - exampleScript.js:
second file without class - exporttrial.js:
What browser did you use?
Chrome, Firefox, Edge
How to reproduce
Relevant log output