I need to download a csv file from my app using Open::URI and to do that I need to give it a fully qualified URI. So whats the best way to get the HOST and more importantly PORT in my cucumber script?
Note I am using Capybara and Selenium
I need to download a csv file from my app using Open::URI and to do that I need to give it a fully qualified URI. So whats the best way to get the HOST and more importantly PORT in my cucumber script?
Note I am using Capybara and Selenium
You can set port that will be used to spawn an application server
Capybara.server_port = 31337
ruby Capybara.server_host = '0.0.0.0'
–
Cystine For capybara < 2.0:
Capybara.current_session.driver.rack_server.host
Capybara.current_session.driver.rack_server.port
Capybara 2.0:
Capybara.current_session.server.host
Capybara.current_session.server.port
FYI, my use case is having clickable links in the mail generated by the integration tests.
Capybara.current_session.server
returns nil
for me –
Matrix Capybara.current_session.server
with Capybara 2.15, but I see that 3.0.0.dev is under development, so if you're using that version I'd say there was a change or a bug. I'll update the answer when I figure that out myself –
Lennalennard You can set port that will be used to spawn an application server
Capybara.server_port = 31337
ruby Capybara.server_host = '0.0.0.0'
–
Cystine 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).
© 2022 - 2024 — McMap. All rights reserved.