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