Appium 学习笔记:PO 模式设计及代码应用 (上)

大海 · 2020年02月22日 · 735 次阅读

测试数据

  • Appium Desktop V1.15.1
  • PyCharm Community 2019.2
  • 夜神模拟器 V6.6.0.2
  • 雪球股票 APK V12.4.6

原始代码

# !/usr/bin/env python
# -*- coding:utf-8 -*-

"""
@File    : demo.py
@Time    : 2020/02/22
"""


from appium import webdriver
import pytest


class TestSearchFunc():
    def setup(self):
        desire_cap = {}
        desire_cap['platformName'] = 'Android'
        desire_cap['platformVersion'] = '5.1.1'
        desire_cap['deviceName'] = 'emulator-5554'
        desire_cap['appPackage'] = 'com.xueqiu.android'
        desire_cap['appActivity'] = 'view.WelcomeActivityAlias'
        self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desire_cap)
        self.driver.implicitly_wait(10)

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

    def test_search01(self):
        self.driver.find_element_by_xpath("//android.widget.TextView[@text='同意']").click()
        self.driver.find_element_by_id("com.xueqiu.android:id/tv_search").click()
        self.driver.find_element_by_id("com.xueqiu.android:id/search_input_text").send_keys("alibaba")
        self.driver.find_element_by_xpath("//android.widget.TextView[@text='阿里巴巴']").click()
        current_price = float(self.driver.find_element_by_id("com.xueqiu.android:id/current_price").text)
        print((current_price))
        assert current_price > 150


if __name__ == '__main__':
    pytest.main()


如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册