I am using watir for testing my rails 3 webapplication which is working fine.
My problem is, my current page url is localhot:3000/sites/535/ecosystem/new
. NOw:
localhost:3000/sites/535/ecosystem/new
But my problem is I am using datatable for displaying sites, and it is sorting site list with sitename.
One solution I got for this problem is, If I can fetch @id = params[:id]
from localhost:3000/sites/535/ecosystem/new
then I can do:
@browser.goto "localhost:3000/sites/#{@id}"
which is the url for my site link in dashboard page.
HOW TO FETCH params[:id]
from current URL in watir or watir-webdriver?
thanks
I have resolved this problem with ruby logic, but still waiting for some good logic.
Solution
url = @browser.url
#> ["localhost:3000/sites/535/ecosystem/new"]
uri = url.split("/sites/")
#> ["localhost:3000", "535/ecosystem/new"]
uri = uri[1].split("/ecosystem/new")[0]
#> "535"
I can now access id
i.e 535
in current url. But still wating for some good logic for resolving this issue.
Thanks