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
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
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
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
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 there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #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
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










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.