Search code examples
urlrspecwatir-webdriverassertion

Rspec; Assert new window URL string


I would like to put together an assertion that, when I open a new window, asserts that the URL now includes ?preview=true
What I have so far:

p @browser.url.include? '?preview=true'

However, when I go to run this, it always returns false.
If I run

p @browser.url

It reads the url correctly (including, obviously, the "?preview=true" part of the string)
Is there a method I'm missing for reading part of a url string?


Solution

  • I think you're on the right track. For the Rspec assertion, you should be able to try something like this for the partial url:

    @browser.url.should include('?preview=true')
    

    You can also do the following for the full url:

    @browser.url.should == "google.com"