import
io.appium.java_client.android.AndroidDriver
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
org.openqa.selenium.By
;
import
org.openqa.selenium.WebElement
;
import
org.openqa.selenium.remote.DesiredCapabilities
;
import
org.testng.annotations.BeforeSuite
;
import
org.testng.annotations.Parameters
;
import
org.testng.annotations.Test
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.AfterClass
;
public
class
Suite1
{
public
String
port
;
public
String
udid
;
private
AndroidDriver
driver
;
@Test
public
void
switches
()
throws
InterruptedException
{
WebElement
sound
=
driver
.
findElementByAndroidUIAutomator
(
"new UiSelector().text(\"Sound\")"
);
sound
.
click
();
System
.
out
.
println
(
"checked"
);
Thread
.
sleep
(
2000
);
System
.
out
.
println
(
Thread
.
currentThread
());
@BeforeSuite
@Parameters
({
"port"
,
"udid"
})
public
void
beforeSuite
(
String
port
,
String
udid
)
{
this
.
port
=
port
;
this
.
udid
=
udid
;
@BeforeClass
public
void
beforeClass
()
throws
MalformedURLException
{
System
.
out
.
println
(
“
port
is
”
+
port
+
“
,
udid
is
" + udid);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("
deviceName
","
device
");
capabilities.setCapability("
automationName
","
Appium
");
capabilities.setCapability("
platformVersion
", "
4.4
");
capabilities.setCapability("
udid
", udid);
capabilities.setCapability("
appPackage
", "
com
.
android
.
settings
");
capabilities.setCapability("
appActivity
", "
.
Settings
");
driver = new AndroidDriver(new URL("
http:
//127.0.0.1:" + port + "/wd/hub"), capabilities);
@AfterClass
public
void
afterClass
()
{
driver
.
quit
();
二、连接两个 Android 设备或启动两个虚拟机
adb devices
获取 udid
三、项目路径下新建两个 testng.xml
testng1.xml
<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite1">
<parameter name = "port" value = "4723"/>
<parameter name = "udid" value = "emulator-5554"/>
<test name="Test">
<classes>
<class name="com.testerhome.Suite1"/>
</classes>
</test>
</suite>
testng2.xml
<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite2">
<parameter name = "port" value = "4725"/>
<parameter name = "udid" value = "emulator-5556"/>
<test name="Test">
<classes>
<class name="com.testerhome.Suite1"/>
</classes>
</test>
</suite>
四、开启两个 appium server * 注 2、注 3
如果命令行启动加参数
appium -p 4723 -bp 4724
appium -p 4725 -bp 4726
如果是图形界面,修改:
General Settings 里的 Port ,改为 4723
Android Settings 里的 Bootstrap Port ,改为 4724
General Settings 里的 Port ,改为 4725
Android Settings 里的 Bootstrap Port ,改为 4726
五、导出依赖 * 注 4
因为是用 maven 工程创建的,所以先导出依赖到项目路径下的 lib 文件夹
mvn dependency:copy-dependencies -DoutputDirectory=lib
六、执行测试
先用 Maven 串行执行一次以编译出 Class 文件
mvn clean test
java -classpath ".\target\test-classes" -Djava.ext.dirs=lib org.testng.TestNG -suitethreadpoolsize 2 testng1.xml testng2.xml
如果没有配置 TestNG 环境变量
java -classpath ".\target\test-classes;D:\Programs\testng-6.8\testng-6.8.jar" -Djava.ext.dirs=lib org.testng.TestNG -suitethreadpoolsize 2 testng1.xml testng2.xml
七、查看报告
默认在项目路径下的 test-output 文件夹
这个测试类没有指定 app 路径,如果指定,同时 unzip 的时候会冲突。目前是复制了多个 apk 。
File app = new File(appDir, "AppName"+port+".apk");
并在 appium server 指定不同的临时文件路径,比如:
--tmp D:\tem1
--tmp D:\tem2
两个端口的介绍可以看这两个链接:
appium 自动化测试教程 ppt(第二版)
Appium Android Bootstrap 源码分析之简介
如果使用到 Selendroid 或 Chromium ,还需要指定其他端口(需要修改测试类)
Selendroid port:8080
Selendroid port:8081
Chromium port:9515
Chromium port:9516
本来准备直接用 mvn test 并行执行的,但没试出来传 suitethreadpoolsize 参数的办法
#7 楼 @sanlengjingvv 我执行 mvn clean test 的时候报错
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.
1:testCompile (default-testCompile) on project mytest: Compilation failure: Comp
ilation failure:
[ERROR] /E:/Users/Administrator/workspace/mytest/src/test/java/appiumdemo/mytest
/StuAppTest.java:[13,44] 程序包 org.openqa.selenium.browserlaunchers 不存在
[ERROR] /E:/Users/Administrator/workspace/mytest/src/test/java/appiumdemo/mytest
/TeaAppTest.java:[13,44] 程序包 org.openqa.selenium.browserlaunchers 不存在
这个是为什么
@sanlengjingvv 这样跑的话,生成的测试报告只有一份,testng2.xml 会覆盖 testng1.xml.
我用 maven 的 pom.xml 去配置 testng.xml,但是跑下来的结果是,串行跑,一台跑完去跑另外一台,求指教,如何能并行跑。
代码如下:
org.apache.maven.plugins
maven-surefire-plugin
2.18.1
testng2.xml
testng1.xml
#22 楼 @xiaobanli
这个帖子里没有用 maven 去调用 testng,maven 只是用来管理依赖,最后是导出依赖用命令行调用 testng,在命令行里传入 suitethreadpoolsize 参数利用 testng 提供的多线程功能并行执行。
testng 提供了 test、method、suit 等几种并行方式,开始我也是准备用 maven 调用 testng 的,后来发现 test、method 之类都可以,只有 suit 不能做到并行,但我需要的是 suit 级的并行,所以就换成导出依赖命令行执行这种方式了。
按你的执行方法报告会不会覆盖我没试,不过报告是可以指定目录的,outputDirectory
http://testng.org/doc/documentation-main.html#logging-xml-reports
info: Welcome to Appium v1.4.3 (REV a357c7fa73222315dd85c3d2dd8334767cca1b0d)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: Console LogLevel: debug
info: --> POST /wd/hub/session {"desiredCapabilities":{"automationName":"Appium"
,"platformName":"Android","deviceName":"device","platformVerison":"4.3","appActi
vity":".Settings","udid":"emulator-5554","appPackage":"com.android.settings"}}
info: Client User-Agent string: Apache-HttpClient/4.3.3 (java 1.5)
info: [debug] The following desired capabilities were provided, but not recogniz
ed by appium. They will be passed on to any other services running on this serve
r. : platformVerison
info: [debug] Didn't get app but did get Android package, will attempt to launch
it on the device
info: [debug] Creating new appium session 8792a326-e593-4e77-8ca4-e815f4563da2
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.7.0_71
info: [debug] Checking whether adb is present
info: [debug] Using adb from D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe
warn: No app capability, can't parse package/activity
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming it's alr
eady on the device
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe devices
info: [debug] 2 device(s) connected
info: Found device emulator-5554
info: [debug] Setting device id to emulator-5554
info: [debug] Waiting for device to be ready and to respond to shell commands (t
imeout = 5)
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5554 wait-for-device
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5554 shell "echo 'ready'"
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5554 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 18
info: Device API level is: 18
info: [debug] Extracting strings for language: default
info: [debug] Apk doesn't exist locally
info: [debug] Could not get strings, but it looks like we had an old strings fil
e anyway, so ignoring
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5554 shell "rm -rf /data/local/tmp/strings.json"
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Skipping install since we launched with a package instead of an ap
p path
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5554 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device...
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5554 push "C:\Users\luowenping\AppData\Roaming\np
m\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar" /data/lo
cal/tmp/
info: [debug] Pushing settings apk to device...
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5554 install "C:\Users\luowenping\AppData\Roaming\npm\
node_modules\appium\build\settings_apk\settings_apk-debug.apk"
info: [debug] Pushing unlock helper app to device...
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5554 install "C:\Users\luowenping\AppData\Roaming\npm\
node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
info: Starting App
info: [debug] Attempting to kill all 'uiautomator' processes
info: [debug] Getting all processes with 'uiautomator'
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5554 shell "ps 'uiautomator'"
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-tools
\adb.exe -s emulator-5554 shell uiautomator runtest AppiumBootstrap.jar -c io.ap
pium.android.bootstrap.Bootstrap -e pkg com.android.settings -e disableAndroidWa
tchers false
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRun
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.andro
id.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading json...
info: [debug] Waking up device if it's not alive
info: [debug] Pushing command to appium work queue: ["wake",{}]
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
error: Unhandled error: Error: read ECONNRESET
at exports._errnoException (util.js:746:11)
at TCP.onread (net.js:559:26) context: [POST /wd/hub/session {"desiredCapabi
lities":{"automationName":"Appium","platformName":"Android","deviceName":"device
","platformVerison":"4.3","appActivity":".Settings","udid":"emulator-5554","appP
ackage":"com.android.sett]
info: <-- POST /wd/hub/session - - ms - -
info: --> POST /wd/hub/session {"desiredCapabilities":{"automationName":"Appium"
,"platformName":"Android","deviceName":"device","platformVerison":"4.3","appActi
vity":".Settings","udid":"emulator-5554","appPackage":"com.android.settings"}}
info: Client User-Agent string: Apache-HttpClient/4.3.3 (java 1.5)
error: Failed to start an Appium session, err was: Error: Requested a new sessio
n but one was in progress
info: [debug] Error: Requested a new session but one was in progress
at [object Object].Appium.start (C:\Users\luowenping\AppData\Roaming\npm\nod
e_modules\appium\lib\appium.js:139:15)
at exports.createSession (C:\Users\luowenping\AppData\Roaming\npm\node_modul
es\appium\lib\server\controller.js:188:16)
at Layer.handle as handle_request
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\route.js:110:13)
at Route.dispatch (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appi
um\node_modules\express\lib\router\route.js:91:3)
at Layer.handle as handle_request
at C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_modules\
express\lib\router\index.js:267:22
at Function.proto.process_params (C:\Users\luowenping\AppData\Roaming\npm\no
de_modules\appium\node_modules\express\lib\router\index.js:321:12)
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\index.js:261:10)
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\route.js14)
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\route.js:104:14)
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\route.js:104:14)
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\route.js:104:14)
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\route.js:104:14)
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\route.js:104:14)
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\route.js:104:14)
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\route.js:104:14)
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\route.js:104:14)
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\route.js:104:14)
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\route.js:104:14)
at C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\lib\server\co
ntroller.js:39:7
at Layer.handle as handle_request
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\route.js:110:13)
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\route.js:104:14)
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\route.js:104:14)
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\route.js:104:14)
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\route.js:104:14)
at next (C:\Users\luowenping\AppData\Roaming\npm\node_modules\appium\node_mo
dules\express\lib\router\route.js:104:14)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"
A new session could not be created. (Original error: Requested a new session but
one was in progress)","origValue":"Requested a new session but one was in progr
ess"},"sessionId":"8792a326-e593-4e77-8ca4-e815f4563da2"}
info: <-- POST /wd/hub/session 500 169.997 ms - 250
undefined
下面是成功的 server 的日志
info: --> POST /wd/hub/session {"desiredCapabilities":{"automationName":"Appium"
,"platformName":"Android","deviceName":"device","platformVerison":"4.3","appActi
vity":".Settings","udid":"emulator-5556","appPackage":"com.android.settings"}}
info: Client User-Agent string: Apache-HttpClient/4.3.3 (java 1.5)
info: [debug] The following desired capabilities were provided, but not recogniz
ed by appium. They will be passed on to any other services running on this serve
r. : platformVerison
info: [debug] Didn't get app but did get Android package, will attempt to launch
it on the device
info: [debug] Creating new appium session 0f66c23a-6322-4022-9a23-f91655693041
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.7.0_71
info: [debug] Checking whether adb is present
info: [debug] Using adb from D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe
warn: No app capability, can't parse package/activity
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming it's alr
eady on the device
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe devices
info: [debug] 2 device(s) connected
info: Found device emulator-5556
info: [debug] Setting device id to emulator-5556
info: [debug] Waiting for device to be ready and to respond to shell commands (t
imeout = 5)
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5556 wait-for-device
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5556 shell "echo 'ready'"
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5556 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 18
info: Device API level is: 18
info: [debug] Extracting strings for language: default
info: [debug] Apk doesn't exist locally
info: [debug] Could not get strings, but it looks like we had an old strings fil
e anyway, so ignoring
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5556 shell "rm -rf /data/local/tmp/strings.json"
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Skipping install since we launched with a package instead of an ap
p path
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5556 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device...
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5556 push "C:\Users\luowenping\AppData\Roaming\np
m\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar" /data/lo
cal/tmp/
info: [debug] Pushing settings apk to device...
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5556 install "C:\Users\luowenping\AppData\Roaming\npm\
node_modules\appium\build\settings_apk\settings_apk-debug.apk"
info: [debug] Pushing unlock helper app to device...
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5556 install "C:\Users\luowenping\AppData\Roaming\npm\
node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
info: Starting App
info: [debug] Attempting to kill all 'uiautomator' processes
info: [debug] Getting all processes with 'uiautomator'
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5556 shell "ps 'uiautomator'"
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-tools
\adb.exe -s emulator-5556 shell uiautomator runtest AppiumBootstrap.jar -c io.ap
pium.android.bootstrap.Bootstrap -e pkg com.android.settings -e disableAndroidWa
tchers false
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRun
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.andro
id.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading json...
info: [debug] Waking up device if it's not alive
info: [debug] Pushing command to appium work queue: ["wake",{}]
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] [BOOTSTRAP] [debug] Client connected
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5556 shell "dumpsys window"
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action"
:"wake","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: wake
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] Screen already unlocked, continuing.
info: [debug] Pushing command to appium work queue: ["getDataDir",{}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action"
:"getDataDir","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] dataDir set to: /data
info: [debug] Pushing command to appium work queue: ["compressedLayoutHierarchy"
,{"compressLayout":false}]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"\/data","status":0
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action"
:"compressedLayoutHierarchy","params":{"compressLayout":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":false,"status":0}
info: [debug] Getting device API level
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5556 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 18
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5556 shell "am start -S -a android.intent.action.MAIN
-c android.intent.category.LAUNCHER -f 0x10200000 -n com.android.settings/.Setti
info: [debug] Waiting for pkg "com.android.settings" and activity ".Settings" to
be focused
info: [debug] Getting focused package and activity
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5556 shell "dumpsys window windows"
info: [debug] Getting focused package and activity
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5556 shell "dumpsys window windows"
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5556 shell "getprop ro.build.version.release"
info: [debug] Device is at release version 4.3
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to the default of 60 secs
info: [debug] Appium session started with sessionId 0f66c23a-6322-4022-9a23-f916
55693041
info: <-- POST /wd/hub/session 303 23281.405 ms - 74
info: --> GET /wd/hub/session/0f66c23a-6322-4022-9a23-f91655693041 {}
info: [debug] Responding to client with success: {"status":0,"value":{"platform"
:"LINUX","browserName":"Android","platformVersion":"4.3","webStorageEnabled":fal
se,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"netw
orkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired
":{"automationName":"Appium","platformName":"Android","deviceName":"device","pla
tformVerison":"4.3","appActivity":".Settings","udid":"emulator-5556","appPackage
":"com.android.settings"},"automationName":"Appium","platformName":"Android","de
viceName":"emulator-5556","platformVerison":"4.3","appActivity":".Settings","udi
d":"emulator-5556","appPackage":"com.android.settings"},"sessionId":"0f66c23a-63
22-4022-9a23-f91655693041"}
info: <-- GET /wd/hub/session/0f66c23a-6322-4022-9a23-f91655693041 200 2.913 ms
698 {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformV
ersion":"4.3","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnable
d":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContext
Enabled":false,"warnings":{},"desired":{"automationName":"Appium","platformName"
:"Android","deviceName":"device","platformVerison":"4.3","appActivity":".Setting
s","udid":"emulator-5556","appPackage":"com.android.settings"},"automationName":
"Appium","platformName":"Android","deviceName":"emulator-5556","platformVerison"
:"4.3","appActivity":".Settings","udid":"emulator-5556","appPackage":"com.androi
d.settings"},"sessionId":"0f66c23a-6322-4022-9a23-f91655693041"}
info: --> POST /wd/hub/session/0f66c23a-6322-4022-9a23-f91655693041/element {"us
ing":"-android uiautomator","value":"new UiSelector().text(\"Sound\")"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"-androi
d uiautomator","selector":"new UiSelector().text(\"Sound\")","context":"","multi
ple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action"
:"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector()
.text(\"Sound\")","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding new UiSelector().text("Sound") using A
NDROID_UIAUTOMATOR with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Parsing selector: new UiSelector().text("Sound
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String
arg: "Sound"
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[TEXT=Sound]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"ELEMENT":"1"},"st
atus":0}
info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":
"1"},"sessionId":"0f66c23a-6322-4022-9a23-f91655693041"}
info: <-- POST /wd/hub/session/0f66c23a-6322-4022-9a23-f91655693041/element 200
41005.676 ms - 87 {"status":0,"value":{"ELEMENT":"1"},"sessionId":"0f66c23a-6322
-4022-9a23-f91655693041"}
info: --> POST /wd/hub/session/0f66c23a-6322-4022-9a23-f91655693041/element/1/cl
ick {"id":"1"}
info: [debug] Pushing command to appium work queue: ["element:click",{"elementId
":"1"}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action"
:"element:click","params":{"elementId":"1"}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: click
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] Responding to client with success: {"status":0,"value":true,"sessi
onId":"0f66c23a-6322-4022-9a23-f91655693041"}
info: <-- POST /wd/hub/session/0f66c23a-6322-4022-9a23-f91655693041/element/1/cl
ick 200 3721.447 ms - 76 {"status":0,"value":true,"sessionId":"0f66c23a-6322-402
2-9a23-f91655693041"}
info: --> DELETE /wd/hub/session/0f66c23a-6322-4022-9a23-f91655693041 {}
info: Shutting down appium session
info: [debug] Pressing the HOME button
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20130917\sdk\platform-
tools\adb.exe -s emulator-5556 shell "input keyevent 3"
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"shutdown"}
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"OK, shutting down"
,"status":0}
info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRun
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.andro
id.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 60.976
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] UiAutomator shut down normally
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] Responding to client with success: {"status":0,"value":null,"sessi
onId":"0f66c23a-6322-4022-9a23-f91655693041"}
info: <-- DELETE /wd/hub/session/0f66c23a-6322-4022-9a23-f91655693041 200 4958.2
77 ms - 76 {"status":0,"value":null,"sessionId":"0f66c23a-6322-4022-9a23-f916556
93041"}
这是啥问题啊 ,步骤好像有点不明白。
org.testng.TestNGException:
Cannot instantiate class com.AppiumTestTHEARD.NewTest
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:40)
at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:363)
at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:275)
at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:126)
at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:191)
at org.testng.TestClass.getInstances(TestClass.java:100)
at org.testng.TestClass.initTestClassesAndInstances(TestClass.java:86)
at org.testng.TestClass.init(TestClass.java:78)
at org.testng.TestClass.(TestClass.java:41)
at org.testng.TestRunner.initMethods(TestRunner.java:425)
at org.testng.TestRunner.init(TestRunner.java:252)
at org.testng.TestRunner.init(TestRunner.java:222)
at org.testng.TestRunner.(TestRunner.java:171)
at org.testng.remote.support.RemoteTestNG6_10$1.newTestRunner(RemoteTestNG6_10.java:28)
at org.testng.remote.support.RemoteTestNG6_10$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG6_10.java:61)
at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:623)
at org.testng.SuiteRunner.init(SuiteRunner.java:189)
at org.testng.SuiteRunner.(SuiteRunner.java:136)
at org.testng.TestNG.createSuiteRunner(TestNG.java:1375)
at org.testng.TestNG.createSuiteRunners(TestNG.java:1355)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1209)
at org.testng.TestNG.runSuites(TestNG.java:1133)
at org.testng.TestNG.run(TestNG.java:1104)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:29)
... 25 more
Caused by: java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:787)
at org.openqa.selenium.support.ui.FluentWait.(FluentWait.java:96)
at org.openqa.selenium.support.ui.WebDriverWait.(WebDriverWait.java:72)
at org.openqa.selenium.support.ui.WebDriverWait.(WebDriverWait.java:46)
at com.AppiumTestTHEARD.NewTest.(NewTest.java:28)
... 30 more
java -classpath ".\target\test-classes;D:\Programs\testng-6.8\testng-6.8.jar" -Djava.ext.dirs=lib org.testng.TestNG -suitethreadpoolsize 2 testng1.xml testng2.xml
后面跟 2 个 testng.xml 是会同时执行吗,还是执行完一个再执行另一个