William Hawkes
William Hawkes

Reputation: 1

python - selenium script syntax error

Okay, I used selenium to test some automation, which I got to work. I did an export of the script for python. When I tried to run the python script it generated, it gave me a "SyntaxError: invalid syntax" error message. Here's the python script in question:

from selenium import selenium
import unittest, time, re

class WakeupCall(unittest.TestCase):
    def setUp(self):
        self.verificationErrors = []
        self.selenium = selenium("localhost", 4444, "*chrome", "http://the.web.site")
        self.selenium.start()

    def test_wakeup_call(self):
        sel = self.selenium
        sel.open("/index.php#deposit")
        sel.wait_for_page_to_load("30000")
        sel.click("link=History")
        sel.wait_for_page_to_load("30000")
        try: self.failUnless(sel.is_text_present("key phrase number 1."))
        except AssertionError, e: self.verificationErrors.append(str(e))

The last line is what generated the "SyntaxError: invalid syntax" error message. A "^" was under the comma. The rest of the script goes as follows:

    def tearDown(self):
        self.selenium.stop()
        self.assertEqual([], self.verificationErrors)

if __name__ == "__main__":
    unittest.main()

Upvotes: 0

Views: 1623

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798516

Newer versions of Python have changed the exception handler syntax.

except AssertionError as e:

Upvotes: 1

Related Questions