ลงชื่อเข้าใช้บัญชีอีเมล yahoo โดยใช้ Python Selenium webdrive

ฉันต้องลงชื่อเข้าใช้บัญชีอีเมล yahoo โดยใช้ Selenium กับ Python

นี่คือรหัสของฉัน

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("https://login.yahoo.com")

print driver.current_url

logintxt = driver.find_element_by_name("username")
logintxt.send_keys("email")

pwdtxt = driver.find_element_by_name("passwd")
pwdtxt.send_keys("pass")



button = driver.find_element_by_id("login-signin")
button.click()
driver.get("https://mail.yahoo.com")
print driver.current_url

แต่เมื่อฉันพิมพ์ URL ปัจจุบัน มันจะแสดงหน้าเข้าสู่ระบบให้ฉันเสมอ ซึ่งหมายความว่าไม่ได้เข้าสู่ระบบ

มีความคิดเห็นเกี่ยวกับวิธีการแก้ไขหรือไม่? ฉันใช้ Centos 6 กับ python 2.6


person MedYasser.alkahf    schedule 11.08.2015    source แหล่งที่มา


คำตอบ (1)


รอสักครู่ (โดยใช้ WebDriverWait) เพื่อเปลี่ยนเส้นทางคุณไปยังหน้าหลัก yahoo เมื่อเข้าสู่ระบบสำเร็จ ก่อนที่จะไปที่กล่องจดหมาย Yahoo:

from selenium.webdriver.support.wait import WebDriverWait

button = driver.find_element_by_id("login-signin")
button.click()

# give it time to log in
wait = WebDriverWait(driver, 10)
wait.until(lambda driver: driver.current_url == "https://www.yahoo.com/")

driver.get("https://mail.yahoo.com")
person alecxe    schedule 11.08.2015