SelendroidDriver无法解析为类型。当我尝试使用WebDriver driver = new SelendroidDriver(capa);创建一个selendroid驱动程序对象时,我在selendroid中面临此问题。
我添加了selendroid-standalone-0.12.0-with-dependencies和selendroid-client-0.4.2-sources jars来构建路径,下面是代码:
公共课程TestSelendroid {
@Test
public void runSelendroidTest() throws Exception {
SelendroidCapabilities capa = new SelendroidCapabilities("io.selendroid.testapp:0.12.0");
capa.setPlatformVersion(DeviceTargetPlatform.ANDROID10);
capa.setEmulator(true);
WebDriver driver = new SelendroidDriver(capa);
WebElement inputField = driver.findElement(By.id("my_text_field"));
Assert.assertEquals("true", inputField.getAttribute("enabled"));
inputField.sendKeys("Selendroid");
Assert.assertEquals("Selendroid", inputField.getText());
driver.quit();
}
}
这是cmd上selendroid服务器的状态:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
D:\Selendroid Jar>java -jar selendroid-standalone-0.12.0-with-dependencies.jar -
app selendroid-test-app-0.12.0.apk
################# Selendroid #################
################# Configuration in use #################
io.selendroid.SelendroidConfiguration@3be5d207[
port=4444
timeoutEmulatorStart=300000
supportedApps=[selendroid-test-app-0.12.0.apk]
verbose=false
emulatorPort=5560
deviceScreenshot=false
selendroidServerPort=8080
keystore=<null>
keystorePassword=<null>
keystoreAlias=<null>
emulatorOptions=<null>
registrationUrl=<null>
proxy=<null>
serverHost=<null>
keepAdbAlive=false
noWebViewApp=false
noClearData=false
sessionTimeoutSeconds=1800
forceReinstall=false
logLevel=ERROR
deviceLog=true
serverStartTimeout=20000
printHelp=false
]
Jan 09, 2015 12:03:42 PM io.selendroid.SelendroidLauncher launchServer
INFO: Starting selendroid-server port 4444
Jan 09, 2015 12:03:42 PM io.selendroid.server.model.SelendroidStandaloneDriver i
nitApplicationsUnderTest
SEVERE: Ignoring app because it was not found: D:\Selendroid Jar\selendroid-test
-app-0.12.0.apk
Jan 09, 2015 12:03:42 PM io.selendroid.io.ShellCommand exec
INFO: executing command: D:\Android\android-sdk\build-tools\20.0.0\aapt.exe remo
ve C:\Users\user\AppData\Local\Temp\android-driver6507564983638345758.apk META-I
NF/MANIFEST.MF
Jan 09, 2015 12:03:42 PM io.selendroid.io.ShellCommand exec
INFO: executing command: D:\Android\android-sdk\build-tools\20.0.0\aapt.exe remo
ve C:\Users\user\AppData\Local\Temp\android-driver6507564983638345758.apk META-I
NF/CERT.RSA
Jan 09, 2015 12:03:42 PM io.selendroid.io.ShellCommand exec
INFO: executing command: D:\Android\android-sdk\build-tools\20.0.0\aapt.exe remo
ve C:\Users\user\AppData\Local\Temp\android-driver6507564983638345758.apk META-I
NF/CERT.SF
Jan 09, 2015 12:03:43 PM io.selendroid.io.ShellCommand exec
INFO: executing command: D:\Android\android-sdk\build-tools\20.0.0\aapt.exe remo
ve C:\Users\user\AppData\Local\Temp\android-driver6507564983638345758.apk META-I
NF/ANDROIDD.SF
Jan 09, 2015 12:03:43 PM io.selendroid.io.ShellCommand exec
INFO: executing command: D:\Android\android-sdk\build-tools\20.0.0\aapt.exe remo
ve C:\Users\user\AppData\Local\Temp\android-driver6507564983638345758.apk META-I
NF/ANDROIDD.RSA
Jan 09, 2015 12:03:43 PM io.selendroid.io.ShellCommand exec
INFO: executing command: D:\Android\android-sdk\build-tools\20.0.0\aapt.exe remo
ve C:\Users\user\AppData\Local\Temp\android-driver6507564983638345758.apk META-I
NF/NDKEYSTO.SF
Jan 09, 2015 12:03:43 PM io.selendroid.io.ShellCommand exec
INFO: executing command: D:\Android\android-sdk\build-tools\20.0.0\aapt.exe remo
ve C:\Users\user\AppData\Local\Temp\android-driver6507564983638345758.apk META-I
NF/NDKEYSTO.RSA
Jan 09, 2015 12:03:43 PM io.selendroid.io.ShellCommand exec
INFO: executing command: C:\Program Files\Java\jre7\bin\jarsigner.exe -sigalg MD
5withRSA -digestalg SHA1 -signedjar C:\Users\user\AppData\Local\Temp\resigned-an
droid-driver6507564983638345758.apk -storepass android -keystore C:\Users\user\.
android\debug.keystore C:\Users\user\AppData\Local\Temp\android-driver6507564983
638345758.apk androiddebugkey
Jan 09, 2015 12:03:43 PM io.selendroid.SelendroidLauncher launchServer
SEVERE: Error occurred while building server: io.selendroid.exceptions.ShellComm
andException: An error occured while executing shell command: C:\Program Files\J
ava\jre7\bin\jarsigner.exe -sigalg MD5withRSA -digestalg SHA1 -signedjar C:\User
s\user\AppData\Local\Temp\resigned-android-driver6507564983638345758.apk -storep
ass android -keystore C:\Users\user\.android\debug.keystore C:\Users\user\AppDat
a\Local\Temp\android-driver6507564983638345758.apk androiddebugkey
java.lang.RuntimeException: io.selendroid.exceptions.ShellCommandException: An e
rror occured while executing shell command: C:\Program Files\Java\jre7\bin\jarsi
gner.exe -sigalg MD5withRSA -digestalg SHA1 -signedjar C:\Users\user\AppData\Loc
al\Temp\resigned-android-driver6507564983638345758.apk -storepass android -keyst
ore C:\Users\user\.android\debug.keystore C:\Users\user\AppData\Local\Temp\andro
id-driver6507564983638345758.apk androiddebugkey
at io.selendroid.server.model.SelendroidStandaloneDriver.initApplication
sUnderTest(SelendroidStandaloneDriver.java:146)
at io.selendroid.server.model.SelendroidStandaloneDriver.<init>(Selendro
idStandaloneDriver.java:84)
at io.selendroid.server.SelendroidStandaloneServer.initializeSelendroidS
erver(SelendroidStandaloneServer.java:61)
at io.selendroid.server.SelendroidStandaloneServer.<init>(SelendroidStan
daloneServer.java:50)
at io.selendroid.SelendroidLauncher.launchServer(SelendroidLauncher.java
:64)
at io.selendroid.SelendroidLauncher.main(SelendroidLauncher.java:112)
Caused by: io.selendroid.exceptions.ShellCommandException: An error occured whil
e executing shell command: C:\Program Files\Java\jre7\bin\jarsigner.exe -sigalg
MD5withRSA -digestalg SHA1 -signedjar C:\Users\user\AppData\Local\Temp\resigned-
android-driver6507564983638345758.apk -storepass android -keystore C:\Users\user
\.android\debug.keystore C:\Users\user\AppData\Local\Temp\android-driver65075649
83638345758.apk androiddebugkey
at io.selendroid.io.ShellCommand.exec(ShellCommand.java:49)
at io.selendroid.builder.SelendroidServerBuilder.signTestServer(Selendro
idServerBuilder.java:294)
at io.selendroid.builder.SelendroidServerBuilder.resignApp(SelendroidSer
verBuilder.java:153)
at io.selendroid.server.model.SelendroidStandaloneDriver.initApplication
sUnderTest(SelendroidStandaloneDriver.java:142)
... 5 more
Caused by: io.selendroid.exceptions.ShellCommandException:
... 9 more
Exception in thread "main" java.lang.RuntimeException: io.selendroid.exceptions.
ShellCommandException: An error occured while executing shell command: C:\Progra
m Files\Java\jre7\bin\jarsigner.exe -sigalg MD5withRSA -digestalg SHA1 -signedja
r C:\Users\user\AppData\Local\Temp\resigned-android-driver6507564983638345758.ap
k -storepass android -keystore C:\Users\user\.android\debug.keystore C:\Users\us
er\AppData\Local\Temp\android-driver6507564983638345758.apk androiddebugkey
at io.selendroid.server.model.SelendroidStandaloneDriver.initApplication
sUnderTest(SelendroidStandaloneDriver.java:146)
at io.selendroid.server.model.SelendroidStandaloneDriver.<init>(Selendro
idStandaloneDriver.java:84)
at io.selendroid.server.SelendroidStandaloneServer.initializeSelendroidS
erver(SelendroidStandaloneServer.java:61)
at io.selendroid.server.SelendroidStandaloneServer.<init>(SelendroidStan
daloneServer.java:50)
at io.selendroid.SelendroidLauncher.launchServer(SelendroidLauncher.java
:64)
at io.selendroid.SelendroidLauncher.main(SelendroidLauncher.java:112)
Caused by: io.selendroid.exceptions.ShellCommandException: An error occured whil
e executing shell command: C:\Program Files\Java\jre7\bin\jarsigner.exe -sigalg
MD5withRSA -digestalg SHA1 -signedjar C:\Users\user\AppData\Local\Temp\resigned-
android-driver6507564983638345758.apk -storepass android -keystore C:\Users\user
\.android\debug.keystore C:\Users\user\AppData\Local\Temp\android-driver65075649
83638345758.apk androiddebugkey
at io.selendroid.io.ShellCommand.exec(ShellCommand.java:49)
at io.selendroid.builder.SelendroidServerBuilder.signTestServer(Selendro
idServerBuilder.java:294)
at io.selendroid.builder.SelendroidServerBuilder.resignApp(SelendroidSer
verBuilder.java:153)
at io.selendroid.server.model.SelendroidStandaloneDriver.initApplication
sUnderTest(SelendroidStandaloneDriver.java:142)
... 5 more
Caused by: io.selendroid.exceptions.ShellCommandException:
... 9 more
D:\Selendroid Jar>
最佳答案
使用以下步骤解决您的问题:
1-添加selendroid-client-0.10.0 [删除selendroid-client-0.4.2-sources]
2-添加selenium-server-standalone-2.44.0
在上面添加JARS之后,保存程序,然后检查