Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the full URL with the current path in Capybara

I'm new to writing tests in capybara and I'm having trouble getting the current URL of a page. I wrote it like this:

url = page.current_url + page.current_path 

Somehow its just returning the base URL. Help is much appreciated.

like image 503
cloudrunner Avatar asked Dec 11 '13 14:12

cloudrunner


Video Answer


2 Answers

Try this:

url = URI.parse(current_url) 
like image 106
Severin Avatar answered Sep 23 '22 23:09

Severin


from capybara session doc:
Fully qualified URL of the current page

def current_url   driver.current_url end 

Path of the current page, without any domain information

def current_path   URI.parse(current_url).path end 

I think that what you are doing is not right

like image 20
Philidor Avatar answered Sep 26 '22 23:09

Philidor