• 课后作业

    #coding=utf-8

    from appium import webdriver
    import pytest

    class TestAppium:

    def setup(self):
    server="http://localhost:4723/wd/hub"
    caps={}
    caps["platformName"] = "android"
    caps["deviceName"] = "emulator-5554"
    caps["appPackage"] = "com.xueqiu.android"
    caps["appActivity"] = ".view.WelcomeActivityAlias"
    caps["autoGrantPermissions"]=True

    self.driver=webdriver.Remote(server,caps)
    self.driver.implicitly_wait(15)

    @pytest.mark.parametrize("phone,passw",[('64656522222','8766522')])
    def test_wrong_phone(self,phone,passw):
    #登录入口
    login_in=self.driver.find_element_by_id("com.xueqiu.android:id/user_profile_icon")
    login_in.click()

    #登录类型
    login_type=self.driver.find_element_by_id("com.xueqiu.android:id/rl_login_phone")
    login_type.click()

    #登录帐号类型
    login_account=self.driver.find_element_by_id("com.xueqiu.android:id/tv_login_with_account")
    login_account.click()

    #登录手机号
    phone_number=self.driver.find_element_by_id("com.xueqiu.android:id/login_account")
    phone_number.send_keys(phone)

    #登录密码
    password=self.driver.find_element_by_id("com.xueqiu.android:id/login_password")
    password.send_keys(passw)

    login=self.driver.find_element_by_id("com.xueqiu.android:id/button_next")
    login.click()

    assert u"手机号码填写错误" in self.driver.find_element_by_id("com.xueqiu.android:id/md_content").text

    @pytest.mark.parametrize("phone,passw",[('18612977085','8766522')])
    def test_wrong_password(self,phone,passw):
    #登录入口
    login_in = self.driver.find_element_by_id("com.xueqiu.android:id/user_profile_icon")
    login_in.click()

    # 登录类型
    login_type = self.driver.find_element_by_id("com.xueqiu.android:id/rl_login_phone")
    login_type.click()

    # 登录帐号类型
    login_account = self.driver.find_element_by_id("com.xueqiu.android:id/tv_login_with_account")
    login_account.click()

    # 登录手机号
    phone_number = self.driver.find_element_by_id("com.xueqiu.android:id/login_account")
    phone_number.send_keys(phone)

    # 登录密码
    password = self.driver.find_element_by_id("com.xueqiu.android:id/login_password")
    password.send_keys(passw)

    login = self.driver.find_element_by_id("com.xueqiu.android:id/button_next")
    login.click()

    assert u"用户名或密码错误" in self.driver.find_element_by_id("com.xueqiu.android:id/md_content").text


    @pytest.mark.parametrize("search,result",[('alibaba',u'阿里巴巴'),('xiaomi',u'小米'),('google',u'谷歌')])
    def test_search(self,search,result):
    search_touch=self.driver.find_element_by_id("com.xueqiu.android:id/tv_search")
    search_touch.click()

    search_input=self.driver.find_element_by_id("com.xueqiu.android:id/search_input_text")
    search_input.send_keys(search)

    # search_result=[results.text for results in self.driver.find_elements_by_id("com.xueqiu.android:id/name")]

    #判断所给结果是否在搜索结果中
    # assert result in search_result

    search_result=self.driver.find_elements_by_id("com.xueqiu.android:id/name")
    search_result[0].click()

    search_results=[results.text for results in self.driver.find_elements_by_id("com.xueqiu.android:id/stockName")]

    assert result in search_results


    def teardown(self):

    self.driver.quit()
  • #coding:utf-8
    from selenium import webdriver
    import time

    from selenium.webdriver.common.by import By

    class TestModule():

    def setup_method(self):
    self.driver=webdriver.Chrome()


    def test_url(self):
    self.driver.get("http://www.testerhome.com")
    self.driver.find_element(By.LINK_TEXT,"先到先得!第五届中国移动互联网测试开发大会 PPT 提供下载啦").click()
    time.sleep(2)
    self.driver.find_element(By.LINK_TEXT,"https://testerhome.com/topics/19664").click()
    time.sleep(3)
    #获取所有窗口句柄
    handle=self.driver.window_handles
    #切换到刚打开的最新窗口的聚丙
    self.driver.switch_to_window(handle[-1])
    time.sleep(3)
    assert u"有奖投票" in self.driver.page_source
    time.sleep(3)

    def teardown_method(self):
    self.driver.quit()
  • conftest.py

    @pytest.fixture(scope='module')
    def fixture_module():
    logging.info('login')
    yield
    logging.info('总环境清理')


    @pytest.fixture(scope='class')
    def fixture_class():
    logging.info('环境清理')


    @pytest.fixture(scope='function')
    def fixture_function():
    logging.info('初始化')

    @pytest.fixture(scope='module',params=((1,2,3),(4,5,9),(10,2,12),(11,2,1)))
    def fixture_paramas(request):
    return request.param

    test_fixture2.py


    @pytest.mark.usefixtures('fixture_module')
    @pytest.mark.usefixtures('fixture_class')
    class TestA():

    def test_1(self):
    logging.info("test1")
    assert True

    def test_2(self):
    logging.info("test2")
    assert True


    def test_3(self):
    logging.info("test3")
    assert True

    @pytest.mark.usefixtures('fixture_function')
    class TestB():

    def test_4(self):
    logging.info("test4")
    assert True

    def test_5(self):
    logging.info("test5")
    assert True


    # @pytest.mark.parametrize()
    def test_6(self,fixture_paramas):
    logging.info("test6")
    assert fixture_paramas[0]+fixture_paramas[1]==fixture_paramas[2]
    # assert True

    class TestC():
    @pytest.mark.run(order=-1)
    def test_7(self):
    logging.info("test7")
    assert True

    @pytest.mark.run(order=-3)
    def test_8(self):
    logging.info("test8")
    assert True

    @pytest.mark.run(order=-2)
    def test_9(self):
    logging.info("test9")
    assert True
  • 补课中

    #coding=utf-8
    import pytest
    import logging
    __author__ = 'tangyao'
    logging.basicConfig(level=logging.DEBUG)

    def setup_module():
    logging.info("login")

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

    class TestA():

    @classmethod
    def teardown_class(cls):
    logging.info("环境清理")

    def test_1(self):
    logging.info("test1")
    assert True

    def test_2(self):
    logging.info("test2")
    assert True


    def test_3(self):
    logging.info("test3")
    assert True


    class TestB():

    def setup_method(self):
    logging.info("初始化")

    def test_4(self):
    logging.info("test4")
    assert True

    def test_5(self):
    logging.info("test5")
    assert False

    @pytest.mark.parametrize("a,b,c",[(1,2,3),(4,5,6),(10,2,3),(11,2,3)])
    def test_6(self,a,b,c):
    logging.info("test6")
    assert a+b==c

    class TestC():
    @pytest.mark.run(order=-1)
    def test_7(self):
    logging.info("test7")
    assert True

    @pytest.mark.run(order=1)
    def test_8(self):
    logging.info("test8")
    assert True

    @pytest.mark.run(order=-2)
    def test_9(self):
    logging.info("test9")
    assert True


  • 课件作业

    class TestCalc(TestCase):

    def test_add(self):
    c = Calc()
    self.assertEqual(c.add(1, 1), 3)

    def test_above(self):
    c = Calc()
    self.assertTrue(c.above(1,-1))

    self.assertFalse(c.above(10,100))

    self.assertFalse(c.above(1.2,1.2))
  • Author only
  • 有北京职位不

  • 补充几点:
    1:礼物的combo展示是否正常
    2:送礼是否触发长链,触发后数据是消息体,数据是否正确
    3:针对获取不到礼物后是否有默认icon
    4:礼物列表打开后icon展示是否正常
    5:不同礼物的展示效果是否正确
    6:接口容错

  • 顶一个,好职位不能沉