ricksonoliveira
Has anyone by any chance using WSL tried to use open_browser in your tests?
I’ve heard one could do something like open_browser(lv, &System.cmd("wslview", [&1])). But I have no idea how to make WSL or Elixir know how to open my default browser.
Has anyone gone through this and have been victorious? ![]()
Thanks!
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Latest Phoenix Threads
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
chgeuer
Not referring to tests in particular, but on WSL, you can run applications “on the Windows side”, such as
cmd.exe.cmd.exeallows you to provide a shell command.In Bash for example, you can do something like this:
In Elixir, this might be a start:
However, escaping stuff the right way can always be ‘difficult’ (BatBadBut: You can't securely execute commands on Windows - GMO Flatt Security Research)
slouchpie
I had some success with this:
ricksonoliveira
Nice this one worked!
The only problem is adding this function every time I need to open the browser
Will keep it in a notepad!
ricksonoliveira
Good one! Kinda the same path I was trying with System.cmd
sodapopcan
Just add a helper to your
ConnCaseOtherwise, one of you should consider contributing this to PhoenixTest if it’s universal enough (I had to look up what WSL is so I don’t know anything here, but I did do some work around open_browser for that lib).
slouchpie
Do your test files have a line like this:
?
If so, you can just write the function in
test/support/conn_case.exand then it will be available in all your live view tests.slouchpie
Ah, yes. This. I am saying the same thing.
slouchpie
I do not know if it is universal at all. It worked for me, one day. That’s all.
After that, all bets are off
I guarantee nothing!
Life is chaos!
ricksonoliveira
That’s the function we would need to “contribute” to: phoenix_test/lib/phoenix_test/open_browser.ex at main · germsvel/phoenix_test · GitHub
Actually it’s a good idea to contribute, but I still know too little about what’s really going on behind it to contribute, so I’m gonna do some homework and.. who knows, right?
slouchpie
I tried using my answer today and it needed improvement because CSS was not being loaded.
I have a hacky way of making the CSS work (which is better than no way).
First, use this slightly better
open_browser_wslfunction.It is better for 2 reasons:
I usually just slap that function into the block of code in
conn_case.exthat starts with:With the function inside the
usingblock, any test that hasuse MyAppWeb.ConnCasewill be able to callopen_browser_wsl(view).Now for the CSS. Configure the test
Endpointso that static URLs can be resolved. Inconfig/text.exs, add this:and then finally tell the Endpoint (still in the test config file) to use this static path:
The
try/rescueblock is to make sure people who don’t use WSL can still run tests.It’s hacky, for sure, but now CSS will be loaded.
@ricksonoliveira Please mark this answer as the solution. It is better than my previous answer.