• 这个还可以投吗

  • 课间作业:
    department.py

    def delete(self,ID):
    r=requests.get(self.delete_url,{"access_token":WeWork.get_token(),"id":ID}).json()
    self.verbose(r)
    return r

    test_department.py

        def test_delete(self):
    new_department = self.department.create("test",1,1005)
    r = self.department.delete(new_department["id"])
    # print(new_department["id"])
    # print(type(new_department["id"]))

    assert r["errcode"] == 0
    assert r["errmsg"]=="deleted"
    exit_flag =True
    for dept in self.department.list()["department"]:
    if int(new_department["id"]) == dept["id"]:
    exit_flag = False
    assert exit_flag == True
    ``
  • #在企业微信里编写一个添加成员的用例,把代码贴到回复里
    def test_add_member(self):
    # self.driver.find_element(By.CSS_SELECTOR, ".js_add_member").click()
    print(self.driver.page_source)
    self.driver.find_element(By.CSS_SELECTOR, "#username").send_keys("yiyi")
    self.driver.find_element(By.CSS_SELECTOR, "#memberAdd_acctid").send_keys("yiyi")
    self.driver.find_element(By.CSS_SELECTOR, ".ww_telInput_mainNumber").send_keys("15201932873")
    self.driver.find_element(By.CSS_SELECTOR,'.ww_radio').click()
    # self.driver.find_element(By.CSS_SELECTOR,".ww_checkbox").click()
    self.driver.find_element(By.CSS_SELECTOR,".js_btn_continue").click()
  • 课间作业一:

    import requests


    class Test_request_xy1:
    def test_get_login(self):
    url = "https://testerhome.com/api/v3/topics.json"
    r = requests.get(url,params={'limit':2}).json()
    assert r["topics"][-1]['user']['login'] == 'liangqiangWang'
  • 课间作业,访问置顶帖,点击目录

    from time import sleep

    from selenium import webdriver
    from selenium.webdriver.common.by import By


    class Test_xy2:
    def setup(self):
    self.driver = webdriver.Chrome()
    self.driver.get("https://testerhome.com/")
    self.driver.implicitly_wait(3)
    self.driver.set_window_size(1382, 744)

    def teardown(self):
    self.driver.quit()

    def test_xy2(self):
    self.driver.find_element(By.XPATH, "//a[contains(text(), '云测平台-多服务框架开源')]").click()
    sleep(3)
    # self.driver.find_element(By.CSS_SELECTOR, ".toc-container > .btn").click()
    self.driver.find_element(By.XPATH,"//button[contains(@class,'btn-default')]").click()
    sleep(3)
    self.driver.find_element(By.XPATH, "//a[contains(text(),'看板')]").click()
    sleep(3)
    assert "看板" in self.driver.page_source

    课后作业

    import logging
    from time import sleep

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.keys import Keys


    class Test_xy3:
    def setup(self):
    self.driver = webdriver.Chrome()
    self.driver.get("https://testerhome.com/")
    self.driver.implicitly_wait(3)
    self.driver.set_window_size(1382, 744)


    def teardown(self):
    self.driver.quit()

    #最新发布的帖子浏览
    def test_001(self):
    self.driver.find_element(By.XPATH,"//a[text()='社区']").click()
    sleep(3)
    self.driver.find_element(By.XPATH, "//a[text()='最新发布']").click()
    sleep(3)
    page_title = self.driver.title
    assert page_title == '最新创建 · 社区 · TesterHome'

    #社区访问霍格沃兹测试学院,断言未登录是被拒绝的
    def test_002(self):
    self.driver.find_element(By.XPATH, "//a[text()='社团']").click()
    sleep(3)
    self.driver.find_element(By.CSS_SELECTOR,"a[title='霍格沃兹测试学院(hogwarts)']").click()
    sleep(3)
    self.driver.find_element(By.CSS_SELECTOR,".topic-20829 .title > a").click()
    sleep(3)
    assert "访问被拒绝,你可能没有权限或未登录" in self.driver.page_source

    #错误用户名和密码登陆
    def test_003(self):
    self.driver.find_element(By.CSS_SELECTOR,".navbar-right>li:nth-child(2)>a").click()
    sleep(3)
    self.driver.find_element(By.CSS_SELECTOR,"#user_login").send_keys("sss1")
    self.driver.find_element(By.CSS_SELECTOR, "#user_password").send_keys("111")
    self.driver.find_element(By.CSS_SELECTOR,".form-actions .btn-block").click()
    sleep(3)
    assert "没有该用户,请您重新注册" in self.driver.page_source

    #搜索”测试媛“,找到成立的那个帖子,进去后断言标题与搜索出来的标题是对应的
    def test_004(self):
    group = self.driver.find_element(By.CSS_SELECTOR,".form-group .form-control")
    group.send_keys("测试媛")
    group.send_keys(Keys.ENTER)
    # self.driver.find_element(By.CSS_SELECTOR,".hidden-md .fa-search").click()
    self.driver.find_element(By.CSS_SELECTOR,".result:nth-child(4)>.topic>a").click()
    assert "测试媛组织成立啦" in self.driver.find_element(By.CSS_SELECTOR,".media-body:nth-child(1)>.media-heading>span").text

    命令行输入
    pytest --alluredir=/tmp/mu_allure_results
    allure serve /tmp/my_allure_results

  • 访问第一个置顶帖,点击里面的链接,断言预期界面的关键字是否存在

    import pytest
    import time
    import json
    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.action_chains import ActionChains
    from selenium.webdriver.support import expected_conditions
    from selenium.webdriver.support.wait import WebDriverWait
    from selenium.webdriver.common.keys import Keys


    class TestTest2():
    def setup_method(self, method):
    self.driver = webdriver.Chrome()
    self.vars = {}

    def teardown_method(self, method):
    self.driver.quit()

    def wait_for_window(self, timeout=2):
    time.sleep(round(timeout / 1000))
    wh_now = self.driver.window_handles
    wh_then = self.vars["window_handles"]
    if len(wh_now) > len(wh_then):
    return set(wh_now).difference(set(wh_then)).pop()

    def test_test2(self):
    self.driver.get("https://testerhome.com/")
    time.sleep(3)
    self.driver.set_window_size(1382, 744)
    self.driver.find_element(By.CSS_SELECTOR, ".topic-20700 .title > a").click()
    self.vars["window_handles"] = self.driver.window_handles
    time.sleep(4)
    self.driver.find_element(By.LINK_TEXT, "https://www.bagevent.com/event/6038911?bag_track=th_article").click()
    self.vars["win4759"] = self.wait_for_window(2000)
    self.driver.switch_to.window(self.vars["win4759"])
    self.driver.execute_script("window.scrollTo(0,746)")

    assert "活动详情" in self.driver.page_source

  • 我离测开有多远? at October 11, 2019

    感觉和楼主情况很类似,待过的公司都是大厂,但却一直是螺丝钉的工作,感觉技术上需要学习的东西很多,也在转型中,很是迷茫,不知道能够成功

  • import pytest
    import yaml
    import logging

    logging.basicConfig(level=logging.DEBUG)
    def setup_module():
    logging.info("setup_module")

    def teardown_module():
    logging.info("teardown_module")

    @pytest.mark.run(order=1)
    class TestA:
    @classmethod
    def setup_class(self):
    logging.info("login")

    def test_1(self):
    assert 1==2

    def test_2(self):
    assert 1==1

    def test_3(self):
    assert 1==3

    @classmethod
    def teardown_class(cls):
    logging.info("teardown")

    @pytest.mark.run(order=2)
    class TestB:
    def setup(self):
    logging.info("setup")

    def test_4(self):
    assert 2==2

    def test_5(self):
    assert 3==3

    @pytest.mark.parametrize("a,b",[
    (1,1),
    (1,2),
    (3,3) ])
    def test_6(self,a,b):
    assert a==b

    @pytest.mark.run(order=3)
    class TestC:
    @pytest.mark.run(order=6)
    def test_7(self):
    assert 7==8

    @pytest.mark.run(order=4)
    def test_8(self):
    assert 8 ==8

    @pytest.mark.run(order=5)
    def test_9(self):
    assert 9==9

    在terminal中输入命令: pytest testcase/test_collector.py --alluredir=log ##指定测试报告保存路劲
    allure generate --clean log/ -o log/html ## 生成测试报告!

  • 第十期_接口测试_20190926 at September 28, 2019

    作业2

    curl 'https://xueqiu.com/k?q=%E9%98%BF%E9%87%8C%E5%B7%B4%E5%B7%B4' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36' -H 'Sec-Fetch-Mode: navigate' -H 'Sec-Fetch-User: ?1' -H'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' -H 'Sec-Fetch-Site: none' -H 'Referer: https://xueqiu.com/' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: zh-CN,zh;q=0.9' -H 'Cookie: aliyungf_tc=AQAAAH518nVUPgkAjOpdcnbqAVgto1+z; acw_tc=2760828515696389596208260e48f31e0c408ce8f41b3e07715a61e0175d0d; xq_a_token=d831cd39b53563679545656fba1f4efd8e48faa0; xq_r_token=fd2f0f487c8298cad8e7519f1560abb7a18c589d; u=711569638959746; device_id=24700f9f1986800ab4fcc880530dd0ed; Hm_lvt_1db88642e346389874251b5a1eded6e3=1569638963; Hm_lpvt_1db88642e346389874251b5a1eded6e3=1569640039' --compressed 2>&1 -vv|less*
  • 第十期_接口测试_20190926 at September 28, 2019

    第一题

    curl 'https://www.baidu.com/' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: vivian' -H 'Sec-Fetch-Mode: navigate' -H 'Sec-Fetch-User: ?1' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' -H 'Sec-Fetch-Site: none' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: zh-CN,zh;q=0.9' -H 'Cookie: BAIDUID=CDD9236B0D91DFEC02E4A541C4BA67FD:FG=1; PSTM=1537100713; BIDUPSID=31412DAD28A87B24F7325E58EEFDDA6B; BD_UPN=12314753; ispeed_lsm=2; BDUSS=3l3TmNSYjhXQ0ZQV3U1TXlCTXpRMXlKUHBtQkozd2hCYTVkekFLYWhTNHU2NkZkSVFBQUFBJCQAAAAAAAAAAAEAAAAr-vFDeXVlcmd1YWlndWFpMDQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC5eel0uXnpdS; delPer=0; BD_CK_SAM=1; PSINO=5; BD_HOME=1; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; H_PS_PSSID=1451_21103_18560_20881_29522_29721_29568_29221_26350; BDRCVFR[feWj1Vr5u3D]=mk3SLVN4HKm; COOKIE_SESSION=747_0_5_8_5_8_0_0_2_4_0_0_0_0_0_0_1569599767_0_1569634362%7C9%23662151_59_1569310726%7C9' --compressed 2>&1 -vv|less

    请求及响应

    >GET / HTTP/1.1
    > Host: www.baidu.com
    > Connection: keep-alive
    > Pragma: no-cache
    > Cache-Control: no-cache
    > Upgrade-Insecure-Requests: 1
    > User-Agent: Vivian
    > Sec-Fetch-Mode: navigate
    > Sec-Fetch-User: ?1
    > Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
    > Sec-Fetch-Site: none
    > Accept-Encoding: gzip, deflate, br
    > Accept-Language: zh-CN,zh;q=0.9
    > Cookie: BAIDUID=CDD9236B0D91DFEC02E4A541C4BA67FD:FG=1; PSTM=1537100713; BIDUPSID=31412DAD28A87B24F7325E58EEFDDA6B; BD_UPN=12314753; ispeed_lsm=2; BDUSS=3l3TmNSYjhXQ0ZQV3U1TXlCTXpRMXlKUHBtQkozd2hCYTVkekFLYWhTNHU2NkZkSVFBQUFBJCQAAAAAAAAAAAEAAAAr-vFDeXVlcmd1YWlndWFpMDQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC5eel0uXnpdS; delPer=0; BD_CK_SAM=1; PSINO=5; BD_HOME=1; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; H_PS_PSSID=1451_21103_18560_20881_29522_29721_29568_29221_26350; BDRCVFR[feWj1Vr5u3D]=mk3SLVN4HKm; COOKIE_SESSION=747_0_5_8_5_8_0_0_2_4_0_0_0_0_0_0_1569599767_0_1569634362%7C9%23662151_59_1569310726%7C9
    >
    < HTTP/1.1 200 OK
    < Accept-Ranges: bytes
    < Cache-Control: no-cache
    < Connection: Keep-Alive
    < Content-Length: 227
    < Content-Type: text/html
    < Date: Sat, 28 Sep 2019 02:44:42 GMT
    < Etag: "5d7f08a7-e3"
    < Last-Modified: Mon, 16 Sep 2019 03:59:35 GMT
    < Pragma: no-cache
    < Server: BWS/1.1
    < Set-Cookie: BD_NOT_HTTPS=1; path=/; Max-Age=300