Appium appium PO 封装 怎么控制它的流程呢

吴同学 · 2018年04月21日 · 最后由 张飞 回复于 2018年04月22日 · 2307 次阅读

如果我一个登录 case 一个退出登录 case
都是放在 main 中去 循环添加 case 。我怎么控制它的流程。刚接触 ,求指点

还是一个 page 验证一个功能?

最佳回复

首先将各个功能模块进行独立封装,比如封装登录操作 def login():, 退出操作:def logout():
。伪代码如下:


def login():
def logout():

然后你接下来要设计的测试用例是先登录再退出,就可以再封装一个方法比如 def test_loginout_action() 在这个方法先调用登录,再调用退出。

def test_loginout_action()
    def login():
    def logout():
共收到 9 条回复 时间 点赞

流程都可以放在 PO 里哇,哪里用到直接调用啊。
一个 page 页面验证一个功能?不懂
我是直接封装一个模块的页面,测试一个模块的所有场景
也是小白级别的。

用 testng 的 priority 或 dependsOnMethods =

首先将各个功能模块进行独立封装,比如封装登录操作 def login():, 退出操作:def logout():
。伪代码如下:


def login():
def logout():

然后你接下来要设计的测试用例是先登录再退出,就可以再封装一个方法比如 def test_loginout_action() 在这个方法先调用登录,再调用退出。

def test_loginout_action()
    def login():
    def logout():

感谢各位的解答。

皆非 回复

就是一个场景 测试完成,再写另一个场景的逻辑 。 然后批量放进 unittest 去执行 。可以这么理解吗! 可以加个 Q 请教一下吗

吴同学 回复

719910919 也是小白 相互学习

======================================================================
ERROR: test_single_player_mode (main.ChessAndroidTests)

Test the Chess app launches correctly and click on Play button

Traceback (most recent call last):
File "C:\Python27\333.py", line 19, in setUp
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
File "C:\Python27\lib\site-packages\appium\webdriver\webdriver.py", line 36, in init
super(WebDriver, self).init(command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 154, in init
self.start_session(desired_capabilities, browser_profile)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 243, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Invalid Version: lib


Ran 1 test in 0.230s

FAILED (errors=1)
python 端的 log,麻烦各位大神帮我看看是什么问题?我装的是 appium-desktop1.4.0

[Appium] Welcome to Appium v1.7.2
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session {"capabilities":{"alwaysMatch":{"platformName":"Android"},"firstMatch":[{}]},"desiredCapabilities":{"platformVersion":"8.0","deviceName":"PL2GAM1810800834","platformName":"Android","appActivity":".Calculator","appPackage":"com.android.calculator2"}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"platformVersion":"8.0","deviceName":"PL2GAM1810800834","platformName":"Android","appActivity":".Calculator","appPackage":"com.android.calculator2"},null,{"alwaysMatch":{"platformName":"Android"},"firstMatch":[{}]}]
[BaseDriver] Event 'newSessionRequested' logged at 1524388401480 (17:13:21 GMT+0800 (中国标准时间))
[Appium] Merged W3C capabilities {"alwaysMatch":{"platformName":"Android"},"firs... into desiredCapabilities object {"platformVersion":"8.0","deviceName":"PL2GAM18...
[Appium] Creating new AndroidDriver (v1.37.0) session
[Appium] Capabilities:
[Appium] platformVersion: 8.0
[Appium] deviceName: PL2GAM1810800834
[Appium] platformName: Android
[Appium] appActivity: .Calculator
[Appium] appPackage: com.android.calculator2
[BaseDriver] Session created with session id: fd067d70-061c-4e3f-9f23-280c9c8f8c19
[AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.8.0_161
[ADB] Checking whether adb is present
[AndroidDriver] Shutting down Android driver
[AndroidDriver] Called deleteSession but bootstrap wasn't active
[MJSONWP] Encountered internal error running command: TypeError: Invalid Version: lib
at new SemVer (C:\Users\Administrator\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\semver\semver.js:293:11)
at compare (C:\Users\Administrator\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\semver\semver.js:566:10)
at rcompare (C:\Users\Administrator\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\semver\semver.js:576:10)
at Array.sort (native)
at Array.sort (C:\Users\Administrator\AppData\Local\Programs\appium-desktop\resources\app\webpack:~\core-js\modules\es6.array.sort.js:21:1)
at ADB.callee$0$0$ (C:\Users\Administrator\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\system-calls.js:89:17)
at tryCatch (C:\Users\Administrator\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as next
at GeneratorFunctionPrototype.invoke (C:\Users\Administrator\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
at
[HTTP] <-- POST /wd/hub/session 500 147 ms - 157
appium-desktop 端的 log,麻烦了!!!

Sutune 回复

期间要有切换页面的操作吧

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册