selenium(web端)Python自动化访问QQ空间

# oding = utf-8
# -*- coding:utf-8 -*-
from selenium import webdriver
import time

# selenium测试框架
# webdriver驱动

deiver = webdriver.Firefox()  # Firefox是火狐浏览器的意思

# 访问QQ空间
url = "https://qzone.qq.com"
deiver.get(url)
# 定义到表单
value = deiver.find_element_by_css_selector("#login_frame")  # 定义web端的元素   #号的意思的对应的id
# 切换到表单
deiver.switch_to.frame(value)
time.sleep(6)
ele = deiver.find_element_by_id("switcher_plogin")
ele.click()
time.sleep(3)
ele_w = deiver.find_element_by_class_name("inputstyle")
ele_w.send_keys("[email protected]")#qq邮箱
ele_e = deiver.find_element_by_id("p")
ele_e.send_keys("123456")#密码
ele_btn = deiver.find_element_by_id("login_button")
ele_btn.click()
time.sleep(3)

你可能感兴趣的:(selenium(web端)Python自动化访问QQ空间)