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()

相关文章

转载地址:https://www.cnblogs.com/mini-monkey/p/12104821...
web自动化测试过程中页面截图相对比较简单,可以直接使用sel...
目录前言一、Selenium简介二、浏览器驱动1.浏览器驱动参考2....
一、iframe的含义:iframe是HTML中框架的一种形式,在对界面...
转载请注明出处❤️作者:测试蔡坨坨原文链接:caituotuo.to...
'''##**认识selenium**​**下载:pipinstall...