SvenskaSpel/locust-plugins

not able to launch browser with playwright example

Closed this issue · 22 comments

I tried to run locust with playwright example with recording script but browsers not launched and do not see anything in log.Can someone give me detailed steps how to set up pls?

what happens when you try to run one of the examples?

this is what I am getting when set up this project and run locust -f examples/playwright_ex.py with 1 user and 5 seconds to ramp

let me know if i am doing something wrong pls

[2024-02-20 18:05:38,907] Vikash/WARNING/locust.main: Python 3.8 support is deprecated and will be removed soon
[2024-02-20 18:05:38,911] Vikash/INFO/locust.main: Starting web interface at http://localhost:8089 (accepting connections from all network interfaces)
[2024-02-20 18:05:38,938] Vikash/INFO/locust.main: Starting Locust 2.23.1
[2024-02-20 18:06:04,799] Vikash/INFO/locust.runners: Ramping to 1 users at a rate of 5.00 per second

I think the page just never finishes loading. Use a non-headless browser to see what is going on. This is the default when running using run_single_user (just run the example using python playwright_ex.py), but you can also set it manually, I dont remember exactly but I think you can just set a property on the user class.

@cyberw I can see browser set up headless as below:
image

nothing happened when i ran with python command
image

Well, if you're trying to launch a recording, you can also run it directly, and see what happens then.

python examples/playwright-recording.py

If that doesnt tell you anything, try running it in a debugger and confirming exactly where in the python code it gets stuck.

I tried playwright-recording.py directly and it works

when I debug i am getting this
image

oooh... you are on windows :)

The SystemExit exception is just locust exiting, you should read log message printed just before. If you're hitting that code then playwright could not be imported (is not properly installed, and should be solved by just doing pip install locust-plugins[playwright]). but I dont know how you could that error when debugging, and not when running the locustfile from command line... Perhaps different venv:s?

If I have time I'll have a go at launching this on my windows machine...

The problem was one of the flags used when starting chromium (--no-sandbox), it just hangs on windows.

I think it causes a small performance hit on other OS:es but all of this is kind of experimental anyway, so I disabled it.

Try installing the new release (4.4.2). If it doesnt work, try launching locust with --loglevel DEBUG and show me the output.

now with new code, i am getting this
image

No error now but debug also not showing anything wrong

I wonder what your log message about "proactor" is about, I dont think I got that message myself.

The things I fixed only really apply to "regular" locust playwright users, not script based ones (the scripted ones shouldnt have that particular issue, but maybe they have others). Can you run a regular one?

You might wanna update your python version as well. Sorry, thats all the time I have for now.

what do you mean by regular one pls? I updated python. one more question can I run it from WSL on windows?

By regular I meant PlaywrightUser (as opposed to PlaywrightScriptUser). I've never tried this in WSL, no idea if it will work but my guess is that it would not work. I didnt even know running GUI apps (like a browser) in WSL was supported :)

I tried remving playwrightScriptuser class and keep only Playwrightuser class and run script but still same result. Now if i try to run on macOs will it work?

Having same issue. using windows. added 4.4.2 via pip install --upgrade locust-plugins[playwright]

Hangs here
image

Running
locust -f .\LocustTesting.py -u 2 -r 1 --loglevel DEBUG

class ScriptBased(PlaywrightScriptUser):
# run a script that you recorded in playwright, exported as Python Async
script = "playwrightcheck.py"
...

if name == "main":
# import os
# os.system(f'locust -f {file} -u 1 -r 1')
# usr.run()
run_single_user(ScriptBased)

running from python the script runs as expected

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days.

This issue was closed because it has been stalled for 10 days with no activity. This does not necessarily mean that the issue is bad, but it most likely means that nobody is willing to take the time to fix it. If you have found Locust useful, then consider contributing a fix yourself!