To open a page use browser.open . Browser will load a page only if the current url doesn't match the passed one. search.submit('query') browser.open("/search") // page is not be ing refreshed search.searchMessage.should == 'searching for query' Note: relative url will be automatically expanded to the full url based on the browser/basic-configuration configuration
Use brower.reopen to force open the page even if the page url already matches the passed one. search.submit('name') browser.reopen("/search") // page is going to be refreshed search.searchMessage.should == ''
Use browser.refresh to refresh current page. search.submit('name') browser.reopen("/search") // page is going to be refreshed search.searchMessage.should == ''
Use browser.restart to restart a browser and open last opened url. browser.open('/local-storage') browser.localStorage.setItem('favoriteColor', 'pretty') browser.refresh() $('#favorite-color').should == 'pretty' browser.restart() $('#favorite-color').should == '' Note: restarting creates a clean instance of a browser. Local storage is going to be reset.
Use browser.url to assert on or wait for url changes. http://example.com/resource/id?type=full&debug=true#subId browser.url.path.should == '/resource/id' browser.url.path.should contain('/id') browser.url.query.should == 'type=full&debug=true' browser.url.ref.should == 'subId' browser.url.should == 'http://example.com/resource/id?type=full&debug=true#subId' browser.url.should contain('resource/id?type=') browser.url.path.waitTo == '/resource/id' browser.url.query.waitTo == 'type=full&debug=true' browser.url.ref.waitTo == 'subId'
Use browser.saveCurrentUrl to save url in a local cache and browser.openSavedUrl to open a page later.It can be handy in multipart tests where first part creates an entity and the second part updates the created entity. browser.open('/resource-creation') $('#new').click() browser.saveCurrentUrl() In order to simplify tests development of a second part you can run first part once, save URL, and iterate on a second part by opening a page using saved URL. browser.openSavedUrl() // continue resource related manipulations Note: url is stored in a local cache file and will survive tests restart.
browser.title.should == "Super Search" browser.title.waitTo == "Super Search"
Use and to simulate browser history Back and Forward buttons browser.back() browser.forward()