Question

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...

Was it helpful?

Solution 3

A brief update: We gave up trying to use Selenium IDE to write our integration tests, and instead used the Selenium Python bindings for Selenium WebDriver.

With this approach, we can navigate to a URL and then use WebDriverWait to detect a particular change in the DOM, e.g.

driver = webdriver.Firefox()
driver.get("/#/login")
WebDriverWait(driver, 10).until(
    lambda driver: driver.find_element_by_css_selector("form.login").is_displayed())

OTHER TIPS

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.

Run this on console of developer tool -> window.location.hash='#abcde'. It should change hash for you in the browser tab.

Execute javascript through Selenium Webdriver and Java:

((JavascriptExecutor) driver).executeScript("window.location.hash='#abcde'");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top