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

上一篇:Springboot+redis实现手机短信验证功能


下一篇:015、事务的实验