Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to use TestCafe in WSL #5902

Open
AndreyBelym opened this issue Jan 28, 2021 · 5 comments
Open

Document how to use TestCafe in WSL #5902

AndreyBelym opened this issue Jan 28, 2021 · 5 comments
Labels
AREA: docs An issue related to the product documentation. TYPE: enhancement The accepted proposal for future implementation.

Comments

@AndreyBelym
Copy link
Contributor

AndreyBelym commented Jan 28, 2021

We should add the following content to our docs:
#1640 (comment)

For the Chrome Linux option, there are several ways to enable GUI testing:
https://medium.com/@dhanar.santika/installing-wsl-with-gui-using-vcxsrv-6f307e96fac0
https://devblogs.microsoft.com/commandline/whats-new-in-the-windows-subsystem-for-linux-september-2020/#gui-apps

@AndreyBelym AndreyBelym added TYPE: enhancement The accepted proposal for future implementation. AREA: docs An issue related to the product documentation. labels Jan 28, 2021
@Steven-Beasley
Copy link

Steven-Beasley commented Feb 4, 2021

on windows

choco install vcxsrv

run xlaunch from you desktop keep all the defaults except make sure the Disable Access Control is checked

make note of the routing in the system tray.

image

Important to remember whatever the last bit is. Mine was :437:0

open up your wsl shell, I was using ubuntu

sudo apt update
sudo apt upgrade -y

install whatever browsers you want to test
install testcafe per normal

testcafe -v
testcafe -b

if you have no browsers or not all the ones you installed then look at my comments below for items that don't show as installed browsers.

in your home directory run

nano .bashrc

add the following lines to the bottom note on the DISPLAY line this is where I added the :437:0
I've only tested this with edge and chrome

alias chrome='google-chrome "$1" &> /dev/null'
alias chrome:headless='google-chrome --disable-gpu --headless "$1" &> /dev/null'
alias edge='microsoft-edge-dev "$1" &> /dev/null'
alias edge:headless='microsoft-edge-dev --disable-gpu --headless "$1" &> /dev/null'
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):437.0

logout login to your shell

sudo su - root -c exit

test out that you can launch chrome or whatever installed browser you are using.

chrome

If the browser doesn't launch most likely it is a firewall issue and you will need to change the windows firewall to allow public for this app.

Installed browser not showing up

Note if you want the edge browser to work you will need to modified the alias.js in /node_modules/testcafe-browser-tools/lib/alias.js
Add the following line under the edge browser detection don't forget the , on the previous line

linuxBinaries: ['microsoft-edge-dev']

install edge

sudo apt install microsoft-edge-dev

test that the browser is detected

testcafe -b

if it all worked then you should see edge in the output

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Feb 4, 2021
@felis2803 felis2803 removed the STATE: Need response An issue that requires a response or attention from the team. label Feb 8, 2021
@pogasanov
Copy link

Great instruction! One thing, I would rather add you still need to install google chrome on wsl:

sudo apt update && sudo apt -y upgrade && sudo apt -y autoremove
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt -y install ./google-chrome-stable_current_amd64.deb

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jun 12, 2021
@AlexSkorkin AlexSkorkin removed the STATE: Need response An issue that requires a response or attention from the team. label Jun 14, 2021
@illuminatux
Copy link

We should add the following content to our docs: [#1640 (comment)]

Hello, is this already added to your docs? I can't find anything about using WSL in your doc...

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Mar 30, 2022
@AndreyBelym
Copy link
Contributor Author

Hi @illuminatux, unfortunately, we didn't have time to write an article in our docs. But thanks to an excellent recipe provided by @Steven-Beasley and @pogasanov 🤝 it should be a lot easier now

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Mar 30, 2022
@illuminatux
Copy link

illuminatux commented Apr 1, 2022

hello @AndreyBelym, sometimes the remote browser does not work, the browser gets stuck on the "connected..." page.

and one problem with the vcxsrv solution is, that at least the "t.maximizeWindow()" does not work. one must also install a window manager to get it working.

i am now using kali-linux on wls2 where all things are already wired up after the installation of win-kex (their embedded vcssrv version). after exporting the DISPLAY variable, one can also use the windows terminal or VS Code console to launch a browser, but i tend to use the kali-linux terminal. just remember to install kali-linux from microsoft store app and dont try "wsl install" ... the later is not up-to-date

... or just try to get windnows 11 ;)

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Apr 1, 2022
@Artem-Babich Artem-Babich removed the STATE: Need response An issue that requires a response or attention from the team. label Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AREA: docs An issue related to the product documentation. TYPE: enhancement The accepted proposal for future implementation.
Projects
None yet
Development

No branches or pull requests

7 participants