在python中使用selenium登录facebook
我正在用python培训selenium,并尝试登录Facebook。这是我的尝试在python中使用selenium登录facebook,python,selenium,Python,Selenium,我正在用python培训selenium,并尝试登录Facebook。这是我的尝试 from selenium import webdriver from selenium.webdriver.common.by import By with webdriver.Chrome() as d: d.get("http://www.facebook.com") d.implicitly_wait(10) d.find_element(By.ID, &qu
from selenium import webdriver
from selenium.webdriver.common.by import By
with webdriver.Chrome() as d:
d.get("http://www.facebook.com")
d.implicitly_wait(10)
d.find_element(By.ID, "email").send_keys("email")
d.find_element(By.ID, "pass").send_keys("pass")
d.find_element(By.NAME, "login").click()
代码正在工作,浏览器正在打开,详细信息(电子邮件和密码)已输入,但浏览器在单击登录按钮之前很快关闭
如何解决这个问题?我认为这与
with
语句有关,因为它在执行完所有代码后关闭d
。因此,它确实单击了登录
按钮,但在您看到浏览器登录之前,浏览器已关闭。