DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Yash Dave
Yash Dave

Posted on

How did you setup Capybara + Webdrivers on WSL for testing?

I recently started contributing to dev.to's GitHub repository by refactoring some .js files to meet the eslint specs. Some of the files that need to be refactored require multiple other ones to be refactored too at the same time in order to not break certain functionality.

In order to check for that I have been trying to setup the Acceptance testing as specified in the docs + with some online help to check whether all functionality remains as is or not. But I have been hitting various hurdles throughout where either the chrome binary wouldn't be found, post that after installation it posted Invalid Session id or sometimes it would work totally. It's a mystery for me currently.

Any help / pointer in the right direction would be much appreciated :D. Willing to provide any details required for the same!

Top comments (4)

Collapse
 
amorpheuz profile image
Yash Dave

So I managed to get tackle the chrome issue by using WSL's feature to access Windows binaries from Linux and calling the chrome installed to my windows. But the problem I am getting stuck at now is that it isn't able to perform any actions. It opens blank chrome console windows and just sits until it timesout with:

2.1) Failure/Error: visit "/#{user.username}/#{article.slug}/edit"

          Net::ReadTimeout:
            Net::ReadTimeout with #<TCPSocket:(closed)>



          # ./spec/system/articles/user_edits_an_article_spec.rb:20:in `block (2 levels) in <main>'
          # ./spec/rails_helper.rb:85:in `block (3 levels) in <top (required)>'
          # ./spec/rails_helper.rb:85:in `block (2 levels) in <top (required)>'
          # ./spec/support/initializers/rspec_retry.rb:8:in `block (2 levels) in <main>'

     2.2) Failure/Error: VCR.turned_off { ex.run }

          Net::ReadTimeout:
            Net::ReadTimeout with #<TCPSocket:(closed)>



          # ./spec/rails_helper.rb:85:in `block (3 levels) in <top (required)>'
          # ./spec/rails_helper.rb:85:in `block (2 levels) in <top (required)>'
          # ./spec/support/initializers/rspec_retry.rb:8:in `block (2 levels) in <main>'
Enter fullscreen mode Exit fullscreen mode

Also a debug.log file is generated in the repo with content:

[0927/164130.672:ERROR:registration_protocol_win.cc(84)] TransactNamedPipe: The pipe has been ended. (0x6D)
[0927/164130.685:ERROR:file_io_win.cc(193)] LockFileEx: Incorrect function. (0x1)
[0927/164130.693:ERROR:file_io_win.cc(193)] LockFileEx: Incorrect function. (0x1)
[0927/164230.740:ERROR:file_io_win.cc(193)] LockFileEx: Incorrect function. (0x1)
[0927/164230.748:ERROR:file_io_win.cc(193)] LockFileEx: Incorrect function. (0x1)
Enter fullscreen mode Exit fullscreen mode

Seems to be a firewall issue? But disabling windows firewall doesn't allow it through too.

Collapse
 
jbaxter6 profile image
Johnnathan Baxter

Hi did you end up fixing this issue?

Collapse
 
amorpheuz profile image
Yash Dave • Edited on

Hey, the issues I was facing got resolved once WSL2 came out. With WSL2, it became possible to install chrome directly to my Linux distro without any problems. I followed the following steps for Ubuntu 18.04 with bash:

sudo apt install fonts-liberation libappindicator3-1 libasound2 libgbm1 libnspr4 libnss3 libxss1 xdg-utils
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
echo 'alias chrome="google-chrome-stable"' >> ~/.bashrc
exec $SHELL
Enter fullscreen mode Exit fullscreen mode

If you get an error while running dpkg, run sudo apt --fix-broken install after which run the dpkg command again. You can run the following command to test your install:

chrome --headless --disable-gpu --dump-dom https://www.chromestatus.com/
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
mirzalazuardi profile image
Mirzalazuardi Hermawan

thanks , it works. this what I been searching for

An Animated Guide to Node.js Event Lop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.