Python and Selenium: SyntaxError: invalid syntax [closed]

-1

I'm trying to automatically sign in to facebook with the code below,

   from selenium import webdriver
    from selenium.webdriver.support.ui import WebDriverWait
    import unittest

class LoginTest (unittest.Testcase):

    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.get("https://facebook.com.br")

    def test_Login(self):
        driver = self.driver
        facebookUserName  = "[email protected]"
        faceboookPassword = "mypassword"

        #emailfFieldId    = "email"
        emailFieldID = ".//*[@id='email']"
        #passFieldId      = "pass"
        passFieldID = ".//*[@id='pass']"
        loginButtonXpath = "//input[@value='Log In']"
        fbLogoXpath      = "(//a[contains(@href, 'logo')])[1]"


        emailFieldElement = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath(emailFieldID))
        passFieldElement  = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath(passFieldID))
        loginButtoElement = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath(loginButtonXpath)

        emailFieldElement.click()
        emailFieldElement.clear()
        emailFieldElement.send_keys(facebookUserName))

        passFieldElement.click()
        passFieldElement.clear()
        passFieldElement.send_keys(faceboookPassword)
        loginButtoElement.click()

        WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath(loginButtonXpath)

    def tearDown(self):
        self.driver.quit()

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

The error that cmd returns.

  File "facebooklogin.py", line 29
    emailFieldElement.click()
                    ^
SyntaxError: invalid syntax
    
asked by anonymous 13.01.2016 / 14:45

1 answer

2

Whenever you see that the problem is on a line look also in the previous lines, usually errors of # (Syntax Analysis) can be in these previous lines, in your case the problem is here:

loginButtoElement = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath(loginButtonXpath)

The correct thing is this:

loginButtoElement = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath(loginButtonXpath))

A ) was missing at the end.

    
13.01.2016 / 15:42