【selenium实战2】selenium企业微信实战2

作业

  • 点击add member,po的封闭,并完成断言

https://github.com/shexiaoheng/webwechat_2

https://github.com/shexiaoheng/webwechat_2/blob/master/webchat/page/base_page.py

https://github.com/shexiaoheng/webwechat_2/blob/master/webchat/page/index.py

https://github.com/shexiaoheng/webwechat_2/blob/master/webchat/page/add_member.py

https://github.com/shexiaoheng/webwechat_2/blob/master/webchat/testcase/test_add_member.py

老师,关于最后那个断言,我有个疑问,通讯录列表不是按添加顺序排序的,如果本身有3个以上的成员,添加的新成员在中间应该怎么断言啊?

一、代码
1、pageobject实现
https://github.com/gqxjones/MyprojectHogwarts/tree/master/pageobject/page
2、测试用例实现
https://github.com/gqxjones/MyprojectHogwarts/tree/master/pageobject/testcase
二、测试结果

根据老师的回答,使用find_elements解决了问题,github代码已更新

作业:点击add member,po的封闭,并完成断言

https://github.com/ZHHAYO/TestingDemo/blob/master/pageobject2/testcase/test_add_member.py

作业:点击add member,po的封闭,并完成断言
https://github.com/August-A/HogwartsPythonTesting/tree/master/pageobject2

首页po

添加人员po
https://github.com/zhengytou/HogwartsLagouTesting/blob/master/pageobject/page/add_member.py
测试添加人员及断言
https://github.com/zhengytou/HogwartsLagouTesting/blob/master/pageobject/testcase/test_add_member.py

https://github.com/hd092336/Hogwarts/blob/master/testing/test_page_object.py

from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait


class BasePage:
    def __init__(self, dr=None):
        if dr is None:
            self.dr = webdriver.Chrome()
        else:
            self.dr = dr

    def click(self, locate):
        element = WebDriverWait(self.dr, 5).until(expected_conditions.element_to_be_clickable(locate))
        element.click()

    def type(self, locate, msg):
        self.dr.find_element(*locate).send_keys(msg)


class Index(BasePage):
    a_contacts = (By.ID, "menu_contacts")

    def goto_contact(self):
        self.click(self.a_contacts)
        return Contacts(self.dr)


class Contacts(BasePage):
    a_add_member = (By.CSS_SELECTOR, "div.js_operationBar_footer>.qui_btn.ww_btn.js_add_member")
    input_username = (By.CSS_SELECTOR, "#username")
    input_acctId = (By.CSS_SELECTOR, '#memberAdd_acctid')
    input_phone = (By.CSS_SELECTOR, "#memberAdd_phone")
    checkbox_sendInvite= (By.NAME, "sendInvite")
    button_save = (By.CSS_SELECTOR, ".qui_btn.ww_btn.js_btn_save")

    def add_member(self, username, acct_id, phone_number):
        sleep(10)
        self.click(self.a_add_member)
        self.type(self.input_username, username)
        self.type(self.input_acctId, acct_id)
        self.type(self.input_phone, phone_number)
        self.click(self.checkbox_sendInvite)
        self.click(self.button_save)


class TestWorkWeiChat:
    # 前提: 浏览器已登录企业微信
    def setup_class(self):
        chrome_opts = webdriver.ChromeOptions()
        chrome_opts.debugger_address = "127.0.0.1:9222"
        self.dr = webdriver.Chrome(options=chrome_opts)
        self.dr.implicitly_wait(5)

    def teardown_class(self):
        self.dr.quit()

    def test_add_member(self):
        index = Index(self.dr)
        contact = index.goto_contact()
        contact.add_member("Hogwarts", "1111", "13012345678")

作业还是需要交一下,,
https://github.com/tangfeng-sys/tangfeng/tree/master/pageobject22

作业

点击add member,po的封闭,并完成断言

chrome -remote-debugging-port=9222

https://github.com/tao12d/testpro_calc/tree/master/selenium_wc_homework

作业:点击add member,po的封闭,并完成断言

https://github.com/yyn0918/PageObject/blob/master/page/add_member.py

https://github.com/yyn0918/PageObject/blob/master/page/index.py

https://github.com/yyn0918/PageObject/blob/master/testcase/test_add_member.py

作业

base_page

add_member

index
https://github.com/whiteParachute/PythonTest/blob/master/selenium_3/page/index.py

test_case
https://github.com/whiteParachute/PythonTest/blob/master/selenium_3/testcase/test_add_member.py

testcase:
https://github.com/mengqiD11/qiyeweixin2/blob/master/testcase/test_one.py

page:
https://github.com/mengqiD11/qiyeweixin2/blob/master/page/basePage.py
https://github.com/mengqiD11/qiyeweixin2/blob/master/page/addMember.py
https://github.com/mengqiD11/qiyeweixin2/blob/master/page/indexPage.py

https://github.com/lulihui12/selenium_test

作业:https://github.com/Liyb0326/LagouProject/tree/test/selenium1

作业地址

作业地址

https://github.com/tim8709/hogwarts_testing/blob/master/web/selenium/page/base_page.py
https://github.com/tim8709/hogwarts_testing/blob/master/web/selenium/page/add_member.py
https://github.com/tim8709/hogwarts_testing/blob/master/web/selenium/testcase/test_add_member.py

https://github.com/GongBin-0923/selenium/tree/master/selenium3