今天分享一个CSDN登录模块的登录场景
1.配置文件
CSDNconf.py:
from selenium import webdriver options = webdriver.ChromeOptions() options.binary_location = r"D:\Program Files\360\360se6\Application\360se.exe" # 360浏览器安装地址 driver = webdriver.Chrome(executable_path=r'D:\Python\Python311\chromedriver.exe',options=options)
2.登陆文件
CSDNlogin.py
from selenium.webdriver.common.by import By import CSDNconf class Login(): def login(self): CSDNconf.driver.get("https://passport.csdn.net/") CSDNconf.driver.maximize_window() #点击密码登录 CSDNconf.driver.find_element(By.XPATH,"/html/body/div[2]/div/div[2]/div[2]/div[2]/div/div[1]/span[4]").click() #输入用户名 CSDNconf.driver.find_element(By.XPATH,"/html/body/div[2]/div/div[2]/div[2]/div[2]/div/div[2]/div/div[1]/div/input").send_keys("627168856@qq.com") #输入密码 CSDNconf.driver.find_element(By.XPATH,"/html/body/div[2]/div/div[2]/div[2]/div[2]/div/div[2]/div/div[2]/div/input").send_keys("?love717") # 勾选我已阅读并同意 服务条款 和 隐私协议 CSDNconf.driver.find_element(By.XPATH,"/html/body/div[2]/div/div[2]/div[2]/div[2]/div/div[2]/p/div/i").click() #点击登录按钮 CSDNconf.driver.find_element(By.XPATH,"/html/body/div[2]/div/div[2]/div[2]/div[2]/div/div[2]/div/div[4]/button").click()
3.执行文件
executeFile.py
import time import CSDNFBWZ import CSDNconf import CSDNlogin #fbwz=CSDNFBWZ.FBWZ() #fbwz.fb() lg=CSDNlogin.Login lg.login() time.sleep(10) CSDNconf.driver.quit()
执行executeFile.py文章来源:https://www.toymoban.com/news/detail-846986.html
文章来源地址https://www.toymoban.com/news/detail-846986.html
到了这里,关于seleniumUI自动化实例(登录CSDN页面)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!