0

In Rails when we use capybara with selenium then by default they run the rack server for our rails app and we can test it without running the actual app.

So let me explain what does it mean:

so when we configure capybara rspec and selenium for rails then don't need to run your rails server separately, when we run the spec and when we visit any URL of our app in the specs then its working. its happen because it create a rack server in the background .

Now I use Selenoid instead of selenium but the rack server not working. so does selenoid only work with remote url and it not create any rack app?

Let me know if any other info. is required.

Thanks!

rahul mishra
  • 1,390
  • 9
  • 16

1 Answers1

0

Selenoid is a replacement for the selenium grid, and manages the browser instances you're using for testing. It has nothing to do with running the application under test.

The issue you're running into is that Capybara runs the application on the machine you're running the tests on, but when using selenoid the browsers are running on other machines (containers). This means that when Capybara starts up the application and tells the browser to visit https://localhost:<some port>/some/path, the localhost reference is no longer correct for browsers running on other machines. To correct that you need to set Capybara.app_host to the url where the tests are being run as seen from the machines/containers the browser instances are being run on. Depending on exactly how your container network is configured you'll also need to either fix the port used by Capybara to run the app on or specify the Capybara.always_include_port option.

Capybara.app_host = "http://local_machine_as_seen_from_containers" 
Capybara.always_include_port = true

or

Capybara.server_port = 1234 # some port number
Capybara.app_host = "http://local_machine_as_seen_from_containers:#{Capybara.server_port}"
Thomas Walpole
  • 48,548
  • 5
  • 64
  • 78