views:

57

answers:

1

I'm doing a test suite in python based on the code provided by selenium and i get strange assertion errors when checking for the actual page like this:

sel.click("link=Overview")
sel.wait_for_page_to_load("30000")
self.assertEqual("Naaya testing - Subtitlu testare", sel.get_title())

sel.click("link=Portal properties")
sel.wait_for_page_to_load("30000")
self.assertEqual("Naaya testing - Subtitlu testare", sel.get_title())
sel.click("link=Metadata")
sel.wait_for_page_to_load("15000")

Strange in this piece of code is that i get the assertion error only at the first occurence in code, after i changed the first occurence with:

title = sel.get_title()
self.failUnless(title == "Naaya testing - Subtitlu testare","nu sunt "
                "pe pagina principala")

i got rid of the error ,but i still don't get why the second assertion does not fail but the first one do ?

A: 

In python when you use == operator order may make difference. Try "Your strng" == title and check result. Also assertEqual may check type, so correct code will be:

self.assertEqual("Naaya testing - Subtitlu testare", str(sel.get_title()))

or:

self.assertEqual(u"Naaya testing - Subtitlu testare", sel.get_title())

if selenium uses unicode type.

Tomasz Wysocki