selenium_基本使用

2019-07-31 14:55:48 浏览数 (1)

版权声明:Copyright © https://cloud.tencent.com/developer/article/1477131

代码语言:javascript复制
import time

from selenium import webdriver

driver = webdriver.Chrome('utils/chromedriver')
# driver = webdriver.PhantomJS(executable_path='utils/phantomjs')
driver.get('https://mail.qq.com/')
time.sleep(1)

login_frame = driver.find_element_by_id('login_frame')
driver.switch_to.frame(login_frame)

driver.find_element_by_id('switcher_plogin').click()
time.sleep(3)
driver.find_element_by_id('u').send_keys('792071728')
time.sleep(3)
driver.find_element_by_id('p').send_keys('123456')
time.sleep(3)
driver.find_element_by_id('login_button').click()
time.sleep(3)
text = driver.find_element_by_id('err_m').text
print(text)

time.sleep(2)

windows = driver.window_handles
driver.switch_to.window(windows[0])

driver.quit()
# err_m

driver.quit()

0 人点赞