i trying run ruby on rails feature tests on dockerized selenium standalone firefox browser. seems having issues networking because selenium instance can't connect url started capybara.
here's sample docker-compose.yml
file:
ff: image: selenium/standalone-firefox:2.48.2 container_name: firefox-browser web: build: . container_name: my-app volumes: - ".:/home/ubuntu/my-app" command: /bin/bash -l scripts/docker-start-tests.sh ports: - "3000:3000"
and start docker-compose networking enabled:
docker-compose --x-networking
the test script runs rspec command this
rspec ./spec/features/login_spec.rb:43
for docker tests have enabled remote driver capybara:
capybara.register_driver :docker_firefox |app| capybara::selenium::driver.new(app, { browser: :remote, url: "#{env['ff_url']}/wd/hub", desired_capabilities: selenium::webdriver::remote::capabilities.firefox }) end
and call test this:
unless env['ff_url'].nil? capybara.current_driver = :docker_firefox capybara.javascript_driver = :docker_firefox capybara.app_host = "http://my-app:56555" capybara.server_port = "56555" # capybara.server_host = "my-app" end visit root_path save_and_open_screenshot click_link "sign in" ...
i can tail browser container logs , see selenium receives commands capybara. problem cannot connect url provided, can confirm screenshot.
firefox can't establish connection server @ my-app:56555
to better understand problem, started rails app , tried access selenium container. notice can access app selenium container if start rails app ip binding.
rails s puma -b 0.0.0.0
this looks networking problem, can't figure out solution.
how can make selenium container access rails app running rspec feature tests capybara?
capybara (2.6.0) selenium-webdriver (2.48.1)
thanks help.
the server thread rails runs test app in binds capybara.server_host interface (127.0.0.1 default) - can change whatever ip interface docker container can talk machine on - in case possibly
capybara.server_host = '0.0.0.0' # bind interfaces
Comments
Post a Comment