python+selenium+PageObject
2022/1/9 11:03:25
本文主要是介绍python+selenium+PageObject,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
import time from selenium import webdriver from selenium.webdriver.chrome.webdriver import WebDriver from selenium.webdriver.common.by import By class HomePage: login_phone = (By.XPATH, '//form/div[1]/div/div/div/div/input') login_pwd = (By.XPATH, '//input[@placeholder="请输入密码"]') login_bt = (By.XPATH, '//form/div[4]/div/div[1]/div/button') def __init__(self, driver: WebDriver): self.driver = driver def input_phone(self,phone): self.driver.find_element(*self.login_phone).send_keys(phone) def input_pwd(self,passwd): self.driver.find_element(*self.login_pwd).send_keys(passwd) def input_bt(self): self.driver.find_element(*self.login_bt).click() class BaoBeiPage: ordermang=(By.XPATH, '//*[@id="siderbar"]/div[1]/div/ul/div[3]/li/div/i[1]') baobeilist=(By.XPATH, '//a[text()="列表"]') def __init__(self, driver: WebDriver): self.driver = driver def enter_baobeilist(self): time.sleep(20) self.driver.find_element(*self.Ordermang).click() self.driver.find_element(*self.baobeilist).click() driver=webdriver.Chrome() page=HomePage(driver) page.driver.get('http://www.baidu.com') page.input_phone('11111111111') page.input_pwd('654321') page.input_bt()
这篇关于python+selenium+PageObject的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-23使用python部署一个usdt合约,部署自己的usdt稳定币
- 2024-12-20Python编程入门指南
- 2024-12-20Python编程基础与进阶
- 2024-12-19Python基础编程教程
- 2024-12-19python 文件的后缀名是什么 怎么运行一个python文件?-icode9专业技术文章分享
- 2024-12-19使用python 把docx转为pdf文件有哪些方法?-icode9专业技术文章分享
- 2024-12-19python怎么更换换pip的源镜像?-icode9专业技术文章分享
- 2024-12-19Python资料:新手入门的全面指南
- 2024-12-19Python股票自动化交易实战入门教程
- 2024-12-19Python股票自动化交易入门教程