一段时间以来,我一直在寻找课程、教程、书籍等来学习使用 Python 进行 Appium 移动自动化测试,但还没有找到任何东西。
我确实在 Github 上看到了文档,但我希望能找到一些更具交互性的东西。
Udemy 和 Lynda 什么都没有。亚马逊上没有书。
有什么线索吗?
一段时间以来,我一直在寻找课程、教程、书籍等来学习使用 Python 进行 Appium 移动自动化测试,但还没有找到任何东西。
我确实在 Github 上看到了文档,但我希望能找到一些更具交互性的东西。
Udemy 和 Lynda 什么都没有。亚马逊上没有书。
有什么线索吗?
话题值得商榷,但我会尽力指导你让你的决定更容易。首先让我们将 Python 和 Appium 分开。
什么是Appium?
Appium 像服务器一样工作,用 Nodejs 编写并实现 selenium webdriver 。它允许客户端(用任何语言编写的测试用例,在我们的例子中是 Python)触发测试,目标应用程序(应用程序)就像一个网页。目标应用程序将响应发送回节点 js 服务器,节点 js 服务器又将其发送回客户端。
这是一个很好的链接,可以帮助您更详细地了解appium的基本概念
https://automationlab0000.wordpress.com/2018/09/10/appium/
所以从 appium 开始,你不需要对它进行广泛的研究。
安卓 SDK
您需要安装 android SDK,因为它提供了许多工具来帮助自动化,其中一个工具是adb,它会检测您的移动设备,为它们分配设备 ID,您的脚本语言将引用该 ID,以便与 appium 进一步通信。
客户
第三点是您的脚本语言,即 Python 您需要通过在 python 中使用单元测试模块为您的测试场景定义测试用例,有关此模块的更多信息在这里https://docs.python.org/2/library/unittest.html
Selenium 库是内置于 appium 库的,所以你需要在 python 中安装你的 appium 库
下面的链接将帮助您安装 appium 并在 python 中运行您的测试用例
https://automationlab0000.wordpress.com/2018/08/23/first-mobile-automation-script-using-python/
如果你使用的是 Robotframework,你可以参考这里
https://automationlab0000.wordpress.com/2018/08/21/first-automation-script-using-robot-framework/
你很高兴从这里出发。
好的,我得到它的工作。这就是我为让 Appium 站在我这边所做的事情。
Reopen Android Studio, create a basic project, then when you are done setting up the project and finally at the editor, mouse over to the tool bar and click open "Tools" dropdown and you should see "Android", click that and you should see AVD Manager and SDK Manager. If you don't see those 2 then you'll have to recheck all your build paths.
Download Pycharm IDE
If you already know how to use selenium webdriver then this'll be easy as it's all based on selenium webdriver's framework, but with just Appium's keywords. You could base everything on unittest or pytest frameworks and use page object module to set-up a nice clean framework.
If you don't know how to use Selenium Webdriver, I recommend this Udemy course https://www.udemy.com/selenium-webdriver-with-python3/
You must also create an Android device that you'll be doing some testing on from Android Studio -> AVD Manager and actually have the device on first before running a script I suggest copying the code from https://qxf2.com/blog/appium-mobile-automation/ first to make sure your setup is proper, then type everything by scratch from that point on.
The most challenging thing is the setup, not the actual syntax and frameworks itself.
So when you are ready to start finding xpaths and such to write your scripts first: open up your android device from AVD Manager, Second: open up the SDK location -> tools -> bin -> uiautomatorviewer.bat, Third: From the uiautomatorview.bat screen gui you'll see at the top left corner a black phone with android icon and a red one to the right. The left one click...then you'll see the current state of the page your android device is at, the you'll be able to locate xpaths and such. If you don't know what I'm talking about then see an appium course on Java which will show you how to do all this but you'll have to script it in Python.
Well I hope this all helps everyone interested. One day I'll rewrite all this cleaner as I'm at work and typing this in a hurry. Again learn Selenium and watch appium Java tutorials to get an idea of how to use the UI Automator Viewer.