20220710 web 训练营实战进阶

PPT

代码地址

课后调查表

https://jinshuju.net/f/pfn9uU

#封装的是企业微信-新建部门的功能
#问题描述:在创建部门成功的时候,断言提示信息,在po模式中断言失败,调试了下,好像返回的断言信息是空的,但同样的步骤在流水线代码里能正常断言成功,辛苦老师帮忙指点下 感谢 :heavy_heart_exclamation:
“”"

1、首页点击通讯录
2、通讯录页面实现点击“+”号,并选择点击添加部门
3、新建部门页面编辑部门信息并确定
#企业微信首页代码
"""
from selenium import webdriver
from selenium.webdriver.common.by import By

from auto_test_project.we_work.add_department.base import Base
from auto_test_project.we_work.add_department.contact_page import ContactPage


class MainPage(Base):
    def go_to_contact(self):
        #点击通讯录
        self.driver.find_element(By.XPATH,'//*[text()="通讯录"]').click()
        return ContactPage(self.driver)
#企业微信通讯录页代码
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webelement import WebElement
from auto_test_project.we_work.add_department.base import Base
from auto_test_project.we_work.add_department.creat_new_department_page import CreatNewDepartPage


class ContactPage(Base):
    def click_and_choice(self):
        #点击"+"号
        self.driver.find_element(By.XPATH,'//*[text()="添加"]').click()
        #点击添加部门
        self.driver.find_element(By.XPATH, '//*[text()="添加部门"]').click()
        return CreatNewDepartPage(self.driver)
    def get_department_name(self):
        ele=self.driver.find_element(By.ID,'js_tips') # type:WebElement
        aa=ele.text
        print(aa)
        return ele
#部门编辑页面
from selenium.webdriver.common.by import By

from auto_test_project.we_work.add_department.base import Base



class CreatNewDepartPage(Base):
    def edit_departinfo_page(self):
        from auto_test_project.we_work.add_department.contact_page import ContactPage
        self.driver.find_element(By.XPATH,'//*[@name="name"]').send_keys("八一男篮队")
        self.driver.find_element(By.XPATH,'//*[text()="选择所属部门"]').click()
        self.driver.find_elements(By.XPATH, '//*[text()="CBA_TEST"]')[1].click()
        self.driver.find_element(By.XPATH, '//*[text()="确定"]').click()
        return ContactPage(self.driver)
#测试代码

from auto_test_project.we_work.add_department.main_page import MainPage


class TestAddDepartment:
    def setup_class(self):
        self.department=MainPage()
    def test_add_department(self):
        res=self.department.go_to_contact().click_and_choice().edit_departinfo_page().get_department_name()
        print(res.text,type(res))
        assert res.text=="新建部门成功"

完成作业1,使用PO,从通讯录页面 添加成员
作业1地址