❶ 怎麼使用appium連接android模擬器
1、Appium連接sdk中的模擬器
了解android的人都在知道,android sdk中自帶AVD Manager(Android Virtual Device Manager).開發者會使用AVD Manager創建一個android模擬器來調試自己的應用。所以首先我們介紹如何讓Appium連接好我們的模擬器
1) 創建一個AVD,並啟動
點擊Create 後填寫相關信息後,點擊OK,選中AVD後點擊Start
2)啟動appium 點擊右上角的啟動按鈕
啟動成功後,如下圖
或者在cmd命令中輸入:appium
2、Appium連接真機
實際開發的過程中我們可能是直接拿真機來調試。所以Appium如何連接真機呢?原理上和上述方式一致。但真機會稍微復雜一點
1)打開手機的USB調試模式
不同的手機打開調試模式的方式不同。一般都在設置中的開發者模式中打開
2)手機連接電腦
使用數據線連接手機與電腦,然後在cmd中輸入adb devices查看是否連接成功
新手可能會出現兩個問題
一是輸入adb命令時提示不是內部命令或者外部命令
那麼你需要下載一個adb工具包並存放在C:\Windows\System32目錄下(必須強調:與sdk中的adb工具包版本一致!!!!)
二是需要打開手機的usb調試模式並安裝好驅動
之後在cmd中輸入adb devices 提示如下圖則成功
3)啟動appium服務
在cmd命令中輸入:appium
啟動成功
3、Appium連接第三方模擬器
有時候我們可能不太想用真機或者android sdk中自帶的模擬器。而是使用一些三方的android模擬器。例如夜神,逍遙等等
理論上來說可以使用連接真機的方式一樣來嘗試連接。以下案例使用逍遙模擬器來做演示
1)使用adb連接到逍遙模擬器
網上網路了一番後,發現逍遙模擬器的連接方式是:adb connect 127.0.0.1:21503
所以其udid就是127.0.0.1:21503
2)連接到appium 服務
在cmd命令中輸入:appium
啟動成功
❷ adb install和pm install有什麼不同的地方
以下用PM來代表pm install
區別很簡單,adb install是將電腦中的apk文件直接安裝到手機,它可以代替PM的三行代碼,如果使用pm來安裝電腦中的apk文件,那麼命令就很復雜,命令為adb push *.apk/sdcard/
adb shell
pm install /sdcard/*.apk,所以說adb install也就是把上面三行代碼一個命令完成,而PM install,是把手機中的APK文件安裝到手機,不能把電腦中的APK文件安裝到手機,不懂,請追問請採納,謝謝
❸ appium java 用什麼方法喚醒屏幕
一、appium學習方法:
1.下載sdk,學會一些基本命令,adb。。。其中包含手機驅動,鏈接相關的
2.搭建環境,網上有很多教程。
3.試著跑起來簡單的case,學習腳本語言,js、python、ruby。。。appium支持很多種腳本語言,個人學習算是個入門,另外,appium也支持mac測試ios,在國內測試ios各方面較android匱乏情況下,是很不錯選擇,不用再依賴xcode。
二、java學習方法:
如果您是java的初學者,最想知道的莫過於如何才能學好java,以下是幾點建議。
1.奠定java的語法基礎 ,多看看Java入門基礎視頻教程、零基礎 JAVA基礎教程視頻教程這類的課程。
學習java的第一步,就是學會使用java這個程序語言來編寫程序,而學習程序語言的第一步就是熟悉其語法的使用。程序語言就是一門語言,所不同的是這種語言是用來與計算機溝通的,所以若要熟悉語言,使用的方法莫過於多看別人寫的程序,了解別人是如何使用java來解決問題的,然後針對同樣的程序進行練習,並從實例中測試自己是否真正了解到如何解決問題。
2.運用基本的j2seAPI
除了java語言本身的語法之外,懂得運用j2se的API也是一個必要的課題,然而在這么多的API下,您必然想知道哪些API是必要或常用的。我的建議是先掌握字元串處理、異常處理、容器(Container)、輸入/輸出(I/O)、線程(Thread)這幾個主題。
API的內容龐大,沒有任何一本是可以詳細講解每個API如何運用,您也不需要將API背誦下來,您要懂得查詢API文件說明,雖然API文件都是英文的,但基本上只要有基本的英文閱讀能力就足以應付查詢需求。
❹ 如何使用appium的模擬機怎麼用
1、Appium連接sdk中的模擬器
了解android的人都在知道,android sdk中自帶AVD Manager(Android Virtual Device Manager).開發者會使用AVD Manager創建一個android模擬器來調試自己的應用。所以首先我們介紹如何讓Appium連接好我們的模擬器
1) 創建一個AVD,並啟動
點擊Create 後填寫相關信息後,點擊OK,選中AVD後點擊Start
2)啟動appium 點擊右上角的啟動按鈕
啟動成功後,在cmd命令中輸入:appium
2、Appium連接真機
實際開發的過程中我們可能是直接拿真機來調試。所以Appium如何連接真機呢?原理上和上述方式一致。但真機會稍微復雜一點
1)打開手機的USB調試模式
不同的手機打開調試模式的方式不同。一般都在設置中的開發者模式中打開
2)手機連接電腦
使用數據線連接手機與電腦,然後在cmd中輸入adb devices查看是否連接成功
新手可能會出現兩個問題
一是輸入adb命令時提示不是內部命令或者外部命令
那麼你需要下載一個adb工具包並存放在C:\Windows\System32目錄下(必須強調:與sdk中的adb工具包版本一致!!!!)
二是需要打開手機的usb調試模式並安裝好驅動
之後在cmd中輸入adb devices
3)啟動appium服務
在cmd命令中輸入:appium
啟動成功
3、Appium連接第三方模擬器
有時候我們可能不太想用真機或者android sdk中自帶的模擬器。而是使用一些三方的android模擬器。例如夜神,逍遙等等
理論上來說可以使用連接真機的方式一樣來嘗試連接。以下案例使用逍遙模擬器來做演示
1)使用adb連接到逍遙模擬器
網上網路了一番後,發現逍遙模擬器的連接方式是:adb connect 127.0.0.1:21503
所以其udid就是127.0.0.1:21503
2)連接到appium 服務
在cmd命令中輸入:appium
啟動成功
❺ Appium超時錯誤連接到驅動程序時問題,怎麼解決
問題
1. error: Failed to start an Appium session, err was: Error: Requested a new session but one was in progress
之前的會話沒有關閉,然後你又運行了測試實例,也沒有設置覆蓋.
解決:
1.重新停止appium服務,開啟Appium服務
2.在Genarel Setting那裡設置覆蓋Session,重啟Appium
測試結束在AfterClass加driver.quit()
2. error: Failed to start an Appium session, err was: Error: Command failed: C:Windowssystem32cmd.exe /s /c "D:android-sdk-windowsplatform-toolsadb.exe -s adb server version (32) doesn't match this client (36); killing…
wait-for-device"
error: could not installsmartsocketlistener: cannot bind to 127.0.0.1:5037:
沒有鏈接上手機或者模擬器,請確認已經連接成功,重新鏈接
3. error: Android devices must be of API level 17 or higher. Please change your device to Selendroid or upgrade Android on your device.
手機系統低於4.2,appium不支持4.2.2以下的系統,請換一個手機或者模擬器來測試。
4. Error: Permission to start activity denied.
**activity在清單文件裡面沒添加Android:exported="true"的話,你不能直接打開對應的activity,需要從啟動頁activity打開。
exported屬性就是設置是否允許activity被其它程序調用**
5. error: Failed to start an Appium session, err was: Error: Activity used to start app doesn't exist or cannot ve launched! Make usre it exists and is launchable activity
要打開的activity不存在,activity路徑錯誤,改為完整正確的activity路徑
6. error: Failed to start an Appium session, err was: Error: 'java - version' failed. Error: Command failed: C:Windowssystem32cmd.exe /s /c "java -version"
Java版本錯誤,請安裝最新的版本。
7.> info: [debug] Error: Command failed: C:Windowssystem32cmd.exe /s /c "D:android-sdk-windowsplatform-toolsadb.exe -s 8806a0b0 shell "echo 'ready'"error: unknown host service
鏈接手機失敗,重新鏈接手機即可,我就是重新拔插了一下usb
Error: Command failed: C:Windowssystem32cmd.exe /s /c "D:android-sdk-windowsplatform-toolsadb.exe -s 8806a0b0 shell "echo 'ping'""
error: unknown host service
adb被突然佔用導致,例如你在運行用例的時候運行了模擬器。
8. UIAutomatorViewer提示: Unable to connect to adb. Check if adb is installed correctly
解決,sdk升級到了25產生的問題。
解決方法:
將adb.exe復制一份到uiautomatorviewer.bat目錄下
修改uiautomatorviewer.bat文件最後一行(改binddir=%prog_dir%為自己的platform-tools本地路徑)
9 error: Failed to start an Appium session, err was:INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling
When you are at final step to execute test automation script for mobile app testing on a mobile emulator or a virtual device or a real device, you might observe that script execution fails with different kinds of errors, In context to current article you will look at the error and solutions for: INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.
Error in Appium Server:
1
2
3
4
5
6
7
8
Error: Command failed: C:Windowssystem32cmd.exe /s /c
"C:Users{User}-toolsadb.exe -s
emulator-5554 install
"C:Program Files (x86)Appium ode_molesappiumuildsettings_apksettings_apk-debug.apk""
> Failed to install C:Program Files (x86)Appium ode_molesappiumuildsettings_apk
settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install
io.appium.settings without first uninstalling.]
Error in Android studio run console:
1
2
3
4
5
6
7
8
9
org.openqa.selenium.SessionNotCreatedException: A new session could not be created.
(Original error: Command failed: C:Windowssystem32cmd.exe /s /c
"C:Users{User}-toolsadb.exe -s emulator-5554 install
"C:Program Files (x86)Appium ode_molesappiumuildsettings_apksettings_apk-debug.apk""
Failed to install C:Program Files (x86)Appium ode_molesappiumuildsettings_apk
settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install
io.appium.settings without first uninstalling.]
) (WARNING: The server did not provide any stacktrace information)
Command ration or timeout: 0 milliseconds
For the first time when you execute the script itmight pass, but it will fail with above error when you try to execute the same or any other script multiple times. Or when your test script execution fails on the first attempt for some other reason, and when you fix it and execute it again, you might encounter this new issue.
原因:
The reason for this error is that Appium installs 2 mobile applications before executing the script.
1. io.appium.settings
2. io.appium.unlock
Theseare the supportive mobile applications appium utilizes to execute the test automation script in Mobile Emulator or virtual device or a real mobile device.
Ideally Appium should remove these files every time at the end of the script execution or termination, if it is intends to install themevery time a script is executed, or it should conditionally install these apps / apksto the mobile emulator or mobile device.
In your mobile emulator / Virtual Device / Real device, the 2 mobile applications appear as below:
There are multiple ways to troubleshootthis error and go ahead for asuccessful test script execution.
解決辦法
Solution 1: ADB's uninstall command to remove the files.
You can open command prompt, assuming that you already had set the environment variables for ANDROID_HOME and Path variables for sdk tools and platform tools.
And execute commands as shown below:
Solution 2: Uninstall manually
You can open the mobile emulator / virtual device / real device and go to apps and uninstall them.
Solution 3: Write code as part of your test automation script.
As part of your selenium test automation script, you could write instructions to execute the commands provided in solution 1 above, so that this issue would not arise.
Hope this article has been helpful and you are able to proceed further with script execution.
Request to kindly share any of your queries in form of comments, we would try our best to provide any solution for you.
10.出錯信息里含有"ps 'uiautomator',具體信息未 A new session could not be created. (Original error: Command failed: C:Windowssystem32cmd.exe /s /c "C:Userssxie-toolsadb.exe -s emulator-5554 shell "ps 'uiautomator'""
android-appium: A new session could not be created
junitexceptionandroidappium自動化
detail log:
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Command failed: C:Windowssystem32cmd.exe /s /c "C:Userssxie-toolsadb.exe -s emulator-5554 shell "ps 'uiautomator'""
) (WARNING: The server did not provide any stacktrace information)
Command ration or timeout: 0 milliseconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'WL00070299', ip: '10.110.12.39', os.name: 'Windows 8.1', os.arch: 'x86', os.version: '6.3', java.version: '1.8.0_40'
Driver info: driver.version: AndroidDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect..newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
at io.appium.java_client.remote.AppiumProtocolHandShake.createSession(AppiumProtocolHandShake.java:161)
at io.appium.java_client.remote.AppiumProtocolHandShake.createSession(AppiumProtocolHandShake.java:76)
at io.appium.java_client.remote.AppiumCommandExecutor.doExecute(AppiumCommandExecutor.java:111)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:162)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:137)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:88)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:112)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:73)
at com.sky.demo.ContactTest.setUp(ContactTest.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schele(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
==========================================
直接在cmd中執行"C:Windowssystem32cmd.exe /s /c "C:Userssxie-toolsadb.exe -s emulator-5554 shell "ps 'uiautomator'""
bad pid 'uiautomator'", 報錯: bad pid 'uiautomator'
代碼內容為
public class ContactTest {
private AndroidDriver driver;
@Before
public void setUp() throws Exception {
//設置apk的路徑
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "apps");
File app = new File(appDir, "ContactManager.apk");
}
解決辦法:
resolved by this way:
adb.js(C:Program Files (x86)Appium
ode_molesappium
ode_molesappium-adblibadb.js) 中1035 行this.shell("ps '" + name + "'", function (err, stdout) {
對應執行的指令是ps 'uiautomator', Android7不支持這個指令格式,所以執行結果是bad pid 'uiautomator'
目前Appium未對此進行處理,所以需要修改此指令的執行方式
即將
this.shell("ps '" + name + "'", function (err, stdout) {
if (err) return cb(err);
替換成
this.shell_grep("ps", name, function (err, stdout) {
if (err) {
logger.debug("No matching processes found");
return cb(null, []);
}
並增加上面用到的shell_grep函數:
ADB.prototype.shell_grep = function (cmd, grep, cb) {
if (cmd.indexOf('"') === -1) {
cmd = '"' + cmd + '"';
}
var execCmd = 'shell ' + cmd + '| grep ' + grep;
this.exec(execCmd, cb);
};
11.Android 7.0系統的手機無法執行appium腳本的問題
AppiumAppium 版本 1.4.16,Android 設備固件 7.x,執行腳本時,報錯使用語言:python報錯如下:
WebDriverException: Message: A new session could not be created. (Original error: Could not extract PIDs from ps output. PIDS: [], Procs: ["bad pid 'uiautomator'"])
這個是因為appium版本1.4.16使用的uiatumator1.0不支持的原因導致?如果不升級appium版本,是否有解決方案?
解決辦法
uiautomator1.0應該是不支持7.0,不升版本就換用uiautomator2.0吧,或者用下面的改腳本的方法使用。
解決Android 7.0系統的手機無法執行appium腳本的問題,改問題的具體解決方法如下:
找到appium的安裝目錄下的adb.js文件,windows版本的目錄如下:Appium
ode_molesappium
ode_molesappium-adblib
2、打開adb.js,手動修改該文件下的內容,此方法我已經試驗成功。
adb.js 中1035 行this.shell("ps '" + name + "'", function (err, stdout) {
對應執行的指令是ps 'uiautomator', Android7不支持這個指令格式,所以執行結果是bad pid 'uiautomator'
目前Appium未對此進行處理,所以需要修改此指令的執行方式
即將
this.shell("ps '" + name + "'", function (err, stdout) {
if (err) return cb(err);
替換成
this.shell_grep("ps", name, function (err, stdout) {
if (err) {
logger.debug("No matching processes found");
return cb(null, []);
}
並增加上面用到的shell_grep函數:
ADB.prototype.shell_grep = function (cmd, grep, cb) {
if (cmd.indexOf('"') === -1) {
cmd = '"' + cmd + '"';
}
var execCmd = 'shell ' + cmd + '| grep ' + grep;
this.exec(execCmd, cb);
};
網上還有如下的修改解決辦法:以下我未試驗。
ADB.prototype.getPIDsByName = function (name, cb) {
logger.debug("Getting all processes with '" + name + "'");
this.shell("ps '" + name + "'", function (err, stdout) {
if (err) return cb(err);
stdout = stdout.trim();
var procs = [];
var outlines = stdout.split("
");
outlines.shift(); //在該處添加此行代碼
3、重啟appium
技巧
1.每次測試都重新安裝app
為capabilities色設置noReset為true
capabilities.setCapability("noReset", true);
2.中文亂碼
這都是編碼問題:
1.方法1:
Android Studio修改文件編碼的方法,最底部的UTf-8,點擊選GBK就可以了,reload文件。(ps:先把文件內容全選復制一下再轉換編碼,再粘貼,不然文件內容就變亂碼了)
2.方法2:
用的是原來的UTF-8編碼,然後在測試mole的build.gradle裡面添加三行代碼
tasks.withType(JavaCompile){
options.encoding = 'UTF-8'
}
3.清除編輯框EditText內容
這個問題好像是看手機系統的,我之前的手機就會出現sendKeys的時候沒有全選去掉本來的內容,現在都會自動全選覆蓋了,這個也不算問題了。
/**
* 逐字刪除編輯框中的文字
* @param element 文本框架控制項
*/
public void clearText(AndroidElement element){
String className = element.getClass().getSimpleName();
if (className.equals("EditText")){
String text = element.getText();
//跳到最後
driver.pressKeyCode(KEYCODE_MOVE_END);
for (int i = 0; i < text.length(); i ++){
//循環後退刪除
driver.pressKeyCode(BACKSPACE);
}
}else {
print("不是文本輸入框架,無法刪除文字");
}
}
1
4.點擊輸入法鍵盤的回車搜索
方法1:切換輸入法
利用adb命令先切換為自己的輸入法,按了搜索再切換為appium的輸入法
查看當前手機的輸入法
cmd執行下面的的代碼
adb shell ime list -s
可以看到類似下面的結果,
C:UsersLITP>adb shell ime list -s
com..input_mi/.ImeService
com.sohu.inputmethod.sogou.xiaomi/.SogouIME
io.appium.android.ime/.UnicodeIME
C:UsersLITP>
執行adb命令
先寫好一個執行cmd的方法
/**
* 執行adb命令
* @param s 要執行的命令
*/
private void excuteAdbShell(String s) {
Runtime runtime=Runtime.getRuntime();
try{
runtime.exec(s);
}catch(Exception e){
print("執行命令:"+s+"出錯");
}
}
在需要搜索的時候執行下面的代碼,切換的輸入法用自己查看列表的輸入法內容,我這里是搜狗輸入法
//使用adb shell 切換輸入法-更改為搜狗拼音,這個看你本來用的什麼輸入法
excuteAdbShell("adb shell ime set com.sohu.inputmethod.sogou.xiaomi/.SogouIME");
//再次點擊輸入框,調取鍵盤,軟鍵盤被成功調出
clickView(page.getSearch());
//點擊右下角的搜索,即ENTER鍵
pressKeyCode(AndroidKeyCode.ENTER);
//再次切回 輸入法鍵盤為Appium unicodeKeyboard
excuteAdbShell("adb shell ime set io.appium.android.ime/.UnicodeIME");
❻ adb命令可以找到android設備,但是運行eclipse的時候appium時候找不到設備,怎麼回
虛擬機設備,有時連接不上時,打開電腦端任務管理器,結束掉adb.exe進程,重啟該虛擬機,一般就正常了,再不行裝個刷機精靈,打開刷機精靈,顯示連接中時就關掉刷機精靈,也能正常的使用adb設備了。
❼ appium如何解決每次都要安裝apk的煩惱
兩種解決方式
1、在cmd命令行執行:appium -a 127.0.0.1 -p 4723 -U (adb devices獲取的設備號) --no-reset
其中,--no--reset是不進行安裝apk
2、在初始化driver中,判斷是否進行安裝,如果已經安裝,就執行許可權或者設置
❽ Appium進行自動化測試的時候,始終無反應,也沒有日誌輸出,請問什麼原因
1. 啟http伺服器:127.0.0.1:4723 2. 根據測試代碼setUp()進行初始化http伺服器建立session象; 3. 始調用adb找連接設備設置設備id 猜測:我連接模擬器設備呢第二篇文章命令行啟使用-U參數指定某設備我現圖形界面啟沒指定設備 4. 等待設備准備響應命令 相關命令: c1: adb.exe -s emulator-5554 wait-for-device c2: adb.exe -s emulator-5554 shell "echo 'ready'" 5.啟logcat志監控 java -jar appium\node_moles\appium\lib\devices\android\helpers\strings_from_apk.jar aimsi.apk c:\windows\temp\com.example.aimsi 條命令讀取apk文件些apk基本信息json描述我例: { "app_name" : "Aimsi", "menu_settings" : "Settings", "title_activity_main" : "MainActivity", "RbtnImsi" : "漢字", "RtxtImsi" : "IMSI_IMEI" } apk屬性信息文件strings.json存設備目錄: c3:adb.exe -s emulator-5554 push "c:\\windows\\temp\\com.example.aimsi\\strings.json" /data/local/tmp 6.讀取apk安裝情況 c4:adb.exe -s emulator-5554 shell "pm list packages -3 com.example.aimsi" 讀結我前已經安裝apk 7.埠映射發給appium httpserver內容經httpserver直接發給設備 c5:adb.exe -s emulator-5554 forward tcp:4724 tcp:4724 8. 弄appiumjar包設備 c6:adb.exe -s emulator-5554 appium\node_moles\appium\build\android_bootstrap\appiumbootstrap.jar /data/local/tmp 網路bootstrap:Bootstrap 快速發Web應用程序前端工具包CSSHTML集合,使用新瀏覽器技術,給Web發提供尚版式 9.哇k安裝unlock_apk-debug.apk c7:adb.exe -s emulator-5554 install appium\node_moles\appium\build\unlock_apk\unlock_apk-debug.apk apk用解鎖屏幕解鎖apk使其調試我猜者吧運行測試程序候看看手機沒apk知道 10.kill掉所uiautomator進程 c8:adb.exe -s emulator-5554 shell "ps|grep 'uiautomator'" 我模擬器沒啟進程 11.執行bootstrap c9:adb.exe -s emulator-5554 uiautomator runtest appiumbootstrap.jar -c io.appium.android.bootstrap.bootstrap 帝原諒我沒管寫面緊跟著uiautomator輸 12.bootstrap始工作 socket打4724埠appiumsocket伺服器准備緒 載入json,喚醒客戶端 等我想想設備apk--設備bootstrap--pcappium http server--測試程序先姑且猜著吧 13. 所設備運行窗口都輸志文件判斷設備已經解鎖繼續 c10:adb.exe -s emulator-5554 shell "mpsys window" 志文件寫pc:appium\node_moles\appium\.mpsys.log 14.啟測試程序 c11:adb.exe -s emulator-5554 shell "am start -S -n com.example.aimsi/.MainActivity" 15.等待測程序獲焦點處超60s模擬器太慢居讀兩窗口才啟功 16.創建session記初候根據setup提交給appium httpserver東東吧sessionid維持工作隊列bootstrap隊列面取命令執行像知道隊列pc設備我覺像pc; 面些內容沒啥看非步步調用 說啥研究些東西仔細做技術尤其測試技術原則用少搞明白底細遇問題候處理起快 吧
❾ 用appium做android移動App的自動化測試時,用python和java語言哪個更好
使用Python編寫貓寧考勤應用注冊模塊的自動化測試
1,進入開發者模式.打開uiautomatorviewer工具
3.簡單介紹unittest框架的使用方法
5;
cmd命令:adb devices .使用uiautomatorviewer工具獲取應用的元素進行定位
4:
手機USB連接電腦.使用adb命令連接真機或模擬器.使用adb命令連接真機或模擬器
2開始第一個簡單的Android UI自動化測試
❿ appium配置好了之後 adb 不是內部或外部命令 也不是可運行程序
沒有配置好adb環境,重新在環境變數里添加好sdk tool目錄,mac則是配置.bash_profile