0

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()
2
  • 1
    Could you please elaborate on the problem? Is there a syntax error? If there is, could you please post the stack dump? Commented Dec 12, 2012 at 5:01
  • What version of python are you using? Your code works fine for me on 2.7. Commented Dec 12, 2012 at 5:18

1 Answer 1

1

Newer versions of Python have changed the exception handler syntax.

except AssertionError as e:
Sign up to request clarification or add additional context in comments.

2 Comments

Here's the command execution and what follows: python3 WakeupCall.py File "WakeupCall.py", line 23 except AssertionError, e: self.verificationErrors.append(str(e)) ^ SyntaxError: invalid syntax Python version is 3.1.2
If this is not everything that was requested in order to give the necessary information to get the help I need, please let me know what I need to do. I'm a relative newbie.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.