Cucumber / Capybara -- how to get the host and port of the current execution Cucumber / Capybara -- how to get the host and port of the current execution selenium selenium

Cucumber / Capybara -- how to get the host and port of the current execution


For capybara < 2.0:

Capybara.current_session.driver.rack_server.hostCapybara.current_session.driver.rack_server.port

Capybara 2.0:

Capybara.current_session.server.hostCapybara.current_session.server.port

FYI, my use case is having clickable links in the mail generated by the integration tests.


You can set port that will be used to spawn an application server

Capybara.server_port = 31337


You can use current_host but I don't know if it contains the port. Alternatively you can use current_url and strip the path (and possibly the query string).