0
I am trying to log automatically on 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 to me.
File "facebooklogin.py", line 29
emailFieldElement.click()
^
SyntaxError: invalid syntax
Great, thanks for the tip !
– Guilherme Lima