Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a URL with a hash using Selenium?

I'm trying to test my Backbone.js web application with Selenium IDE.

Selenium can open my test case's initial URL so long as it's in a fresh browser window -- e.g. open /#/login -- but it times out whenever it tries to open subsequent URLs.

It seems that Selenium is listening for an event that just isn't triggered when only the URL hash changes.

I would imagine this happens any time you're using hashchange + Selenium...

like image 424
jabbett Avatar asked Feb 13 '13 19:02

jabbett


1 Answers

In Selenium IDE simply use the 'storeEval' command, for example :

Command = storeEval
Target = window.location.hash='/search/events/birthdays/1' 

storeEval runs the javascript snippet assigned to "target". What you can then do, is have one test case that opens the start page using the open(url) command, and the rest of your cases changing the hash using the storeEval command.

like image 156
Sasha Brocato Avatar answered Oct 21 '22 18:10

Sasha Brocato