appium

Python Appium 开启Android测试之路

∥☆過路亽.° 提交于 2020-01-12 08:15:16
1、获取 Android app的Activity 打开终端cmd,先cd进入到刚才下载的“新浪.apk”目录下,然后使用aapt dump badging xxx.apk命令获取包内信息。注意,启动类名称一个字母都不能错。 aapt dump badging 新浪.apk cat>d:/log.txt 这样可以将信息指定到某一文件下然后 查看   罪过了,后面发现正常是没有appt.exe 这个应用程序的。可以下载一个放到tools文件下,因为已经配置了环境变量,所以 可以直接使用。 可以从下面拷贝一个到tools下即可。 2、启动微博 #-*-coding:utf-8-*- #Time:2017/7/20 18:06 #Author:YangYangJun import time from appium import webdriver desired_caps = {} desired_caps['platformName'] = 'Android' desired_caps['platformVersion'] = '6.0' desired_caps['deviceName'] = 'N79SIV5PVCSODAQC' desired_caps['appPackage'] = 'com.sina.weibo' desired_caps['appActivity'] =

appium 测试使用的API:

早过忘川 提交于 2020-01-11 17:27:17
https://blog.csdn.net/u010381752/article/details/81874273 下面献上 appium 测试使用的API: 模拟操作类 driver.runAppInBackground(5); //将当前活跃的应用放在后台运行 driver.hideKeyboard(); //隐藏键盘 driver.lockDevice(); //锁屏 driver.openNotifications(); //打开Android的下拉通知栏 driver.isAppInstalled(“com.example.android.apis”) //判断应用是否安装 driver.installApp(“path/to/my.apk”) //安装应用 driver.removeApp(“com.example.android.apis”) //卸载应用 driver.closeApp() //关闭App driver.getContextHandles() //可用上下文,context可以理解为可进入的窗口,如果是native则为native_app,如果是webview为对应webview; driver.context(); //设置上下文 (context),对hybrid app会用到 driver.getAppStringMap(); /

Appium 定位ios元素的方法总结

我的未来我决定 提交于 2020-01-10 20:23:49
Appium使用WebDriverAgent之后,新增了一种定位方法iOSNsPredicate,总结了一下使用方法: name = 'head new' // 等于 name LIKE '*new' // 模糊匹配 name MATCHES '^$' // 正则表达式匹配 name CONTAINS '我的' // 包含 name BEGINSWITH '我的' // 以"我的"开始 name BEGINSWITH '我的' && name ENDSWITH '消息' // 以"我的"开始并且以"消息"结尾 其中属性名参照inspector的属性字段,关键字LIKE,MATCHES,CONTAINS,BEGINSWITH,ENDSWITH必须是大写,匹配的字符需要用单引号 官方参考地址:https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/ios_predicate.md 选择定位方式的判断:   如果显示在界面的文本唯一或是第一个出现:使用accessibility   如果class唯一或是第一个出现:className   ID或class不方便定位,控件属性有明确的匹配规则:iOSNsPredicate   如果有工具可以直接给出准确的xpath:xpath  

python爬取利用appium抓取得到APP课程数据导出到Excel进行分析,练习Python实现app抓取实例

给你一囗甜甜゛ 提交于 2020-01-10 06:19:10
python爬取APP爬取思路和方案选择: 用到的库: openpyxl #导出excel appium #自动化测试工具 思路一 通过抓包软件对APP进行抓包分析, 这种方式可以看到 App 在运行过程中发生的所有请求和响应。得知接口之后可以通过设置合适的请求头和各种参数来发送HTTP或者HTTPS请求接口,接口返回的数据就是想要数据了。 python爬取抓取得到APP课程数据分析,联系Python实现app抓取实例 这种方式一旦实现,基本上算是一劳永逸的,除非接口和返回数据定义发生变化。但是如果一些动态参数设置不对,访问接口则不能得到任何数据,换句话说,只要无法破解参数,这条路就是死路一条。 思路二 通过自动化测试工具模拟手工操作APP进行数据的爬取。通过向自动化测试工具(例如Appium)发送操作指令,驱动设备完成点击、输入、滑动等各种操作,分析页面数据完成数据爬取。 这种方式相比于方式一而言,并不会受限于请求头和动态参数,只要是人工可以操作的,自动化测试工具都可以帮助我们进行完成,而所有的APP的所有功能所有页面用户都可以进行操作,意味着APP内所有的数据都可以拿到。 方案选择 本人在尝试使用方式一的过程中,抓包分析接口之后发现有些动态参数无法搞定,故放弃该方式。采用方式二进行爬取。 爬取核心 Appium启动APP 使用Appium启动APP时需要配置参数

快速查询

↘锁芯ラ 提交于 2020-01-10 00:48:26
adb相关命令 https://www.wanandroid.com/blog/show/2310 待整理内容: appium: 1、夜神模拟器相关配置: https://blog.csdn.net/u013314786/article/details/83216390 2、appium浅显使用: https://blog.csdn.net/jixiangrurui/article/details/79140756 爬虫: 1、入门: http://c.biancheng.net/view/2011.html 来源: CSDN 作者: JR_willbeBetter 链接: https://blog.csdn.net/JR_willbeBetter/article/details/103910046

appium(六)H5页面

孤街醉人 提交于 2020-01-09 00:03:17
1、区分APP是H5还是native   (1)手机进入开发者模式,选择显示页面布局边界,native app中所有的控件都是独立的红框,而web H5是一个完整的大框,里面的可以操作的小控件不独立   (2)adb先连接模拟器,在电脑浏览器打开chrome://inspect使用inspect工具,如果能够在其中看到webview的显示,那么说明这个地方有个webview,是H5页面 。(如果需要inspect,需要翻墙下载一下devtools,否则会出现404) 如下面的两个webview就是H5页面 2、H5页面元素定位   (1)使用appium原生的安卓元素定位   如果H5页面在APP内,则Desired Capabilities的设置和启动APP一样,定位也同样使用appium元素的安卓元素定位,可以使用appium-desktop来查找网页元素   (2)使用selenium的网页元素定位    如果H5页面是在浏览器中,则Desired Capabilities的设置和启动APP不同 :     --1.如果使用Android原生的浏览器打开H5,则使用browserName="Browser" 代替appPackage和appActivity;在appium启动browser时,如果出现chromedriver不匹配的问题,先查看手机安卓的系统应 用中

How do I use same Cucumber step definitions for android and iOS

半腔热情 提交于 2020-01-07 02:57:07
问题 I'm currently beginning an automation project for an app that is identical in flow and design for both Android and iOS. I'm using Ruby with the Cucumber framework. I have begun automating Android and essentially what I need to do is each step definition to have separate code for android and ios kind of like this pseudo-code: Then (/^I click the Login Button$/) do if mobile_platform = android #android locators and code here else #iOS locators and code here end end How would I go about setting

Handling cucumber scenario examples as one scenario

大憨熊 提交于 2020-01-07 02:42:13
问题 I'm having a problem with Cucumber - right now I'm doing a mobile automation and I have features that use scenario outlines - I have a few variables in the scenario : Scenario Outline: Menu items Given the user is on the hamburger menu And the language is <language> Then menu item is <menu item> Examples: | menu item | language | | Search | EN | | Zoeken | NL | | Recherche | FR | | Saved properties | EN | | Bewaarde zoekertjes | NL | | Biens sauvés | FR | | Saved searches | EN | | Bewaarde

appium真机并发运行

时光毁灭记忆、已成空白 提交于 2020-01-06 21:35:44
appium端口和设备是一对一的关系,如果多台设备,都要通过手动执行命令的方式启动,过于麻烦,故直接在程序中开启appium服务,动态分配appium端口 命令:appium -a 127.0.0.1 -p 4723 -U 设备ID 程序动态开启: public AppiumDriverLocalService startAppiumServer(StfDevicesFields fields) { //检测appium服务是否已经启动 boolean isServerRunning = checkIfServerIsRunnning(fields); if (isServerRunning) { return service; } int port = fields.getAppiumServerPort(); AppiumServiceBuilder builder = new AppiumServiceBuilder(); builder.withIPAddress("127.0.0.1"); builder.usingPort(port); builder.withArgument(GeneralServerFlag.SESSION_OVERRIDE); builder.withArgument(GeneralServerFlag.LOG_LEVEL, "error");

Appium/Selenium - assert that element declared as field is NOT displayed

ε祈祈猫儿з 提交于 2020-01-06 20:25:22
问题 I declare a button as field in following fashion: @AndroidFindBy(name = "Schedule") private WebElement calendarButton; ... and later I make sure it's NOT displayed because the app is in some special mode. Assert.assertFalse(this.calendarButton.isDisplayed()); It gives me org.openqa.selenium.NoSuchElementException , but the test is failed. Any ideas how can I make such assertion? The thing I don't want to define By condition a few times in the code, so using property is handy. 回答1: After some