我试图执行以下代码
public static void main(String[] args) throws MalformedURLException {
AndroidDriver<AndroidElement> driver=Capabilities();
//xPath id className, androidUIautomator //tagname[@attribute='value']
//Registration of the device
//driver.findElementByXPath("//android.widget.EditText[@resource-id='iMSSO_Alert1_Continue_button']").click();
//driver.findElementByXPath("//android.widget.EditText[@resource-id='btnAgree']").click();
driver.findElementByXPath("//android.widget.EditText[@resource-id='USER']").sendKeys("aris");
driver.findElementByXPath("//android.widget.EditText[@resource-id='PASSWORD']").sendKeys("kKL2WBU7ggCeMh4izUY4Kg==");
driver.findElementByXPath("//android.widget.EditText[@resource-id='btnLogin']").click();
}}
package appiumsample1;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
public class base1 {
public static AndroidDriver<AndroidElement> Capabilities() throws MalformedURLException {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "My tab");
caps.setCapability("udid", "ce12182cabcaaa27017e"); //Give Device ID of your mobile phone/name of the device
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "8.1.0");
caps.setCapability("appPackage", "com.verizon.launcher.sdnasit");
caps.setCapability("appActivity", "com.verizon.launcher.webview.WebActivity");
caps.setCapability("noReset", "true");
AndroidDriver<AndroidElement> driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), caps);
return driver;
/*public static void main(String[] args) {
//Set the Desired Capabilities
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "My Phone");
caps.setCapability("udid", "ce12182cabcaaa27017e"); //Give Device ID of your mobile phone/name of the device
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "8.1.0");
caps.setCapability("appPackage", "com.verizon.launcher.sdnasit");
caps.setCapability("appActivity", "com.verizon.launcher.webview.WebActivity");
caps.setCapability("noReset", "true");
//Instantiate Appium Driver
try {
AppiumDriver<MobileElement> driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), caps);
} catch (MalformedURLException e) {
System.out.println(e.getMessage());
} */
// UI Automator tool
}
例外
远程会话。有关更多详细信息,请检查服务器日志。原始错误:处理命令时发生未知服务器端错误。原始错误:无法启动com.verizon.launcher.sdnasit应用程序。访问https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md进行故障排除。原始错误:执行adbExec时出错。原始错误:'命令'C:\用户\SINGTO2\AppData\本地\android\sdk\平台工具\adb.exe-P 5037-s ce12182Cabcaaa27017e shell am start-W-ncom.verizon.launcher.sdnasit/com.verizon.launcher.webview.WebActivity-S'在20000ms后超时'。尝试增加由'adbExecTimeout'功能表示的20000ms adb执行超时构建信息:版本:'3.141.59',修订版:'e82be7d358',时间:'2018-11-14T08:25:48'系统信息:主机:'TFL0074ALKVTMLM',ip:'10.69.131.113',os.name:'Windows 10',os.arch:'amd64',os.version:'10.0',java.version:'1.8。0_181'驱动程序信息:driver.version:Android驱动程序远程堆栈跟踪:未知错误:处理命令。原始错误:无法启动com.verizon.launcher.sdnasit应用程序。访问https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md进行故障排除。原始错误:执行adbExec时出错。原始错误:'命令'C:\用户\SINGTO2\AppData\本地\android\sdk\平台工具\adb.exe-P 5037-s ce12182Cabcaaa27017e shell am start-W-ncom.verizon.launcher.sdnasit/com.verizon.launcher.webview.WebActivity-S'在20000ms后超时'。尝试增加由adbExecTimeout功能表示的20000ms adb执行超时
根据答案添加代码
public class base1 {
public AndroidDriver<MobileElement> driver;
public WebDriverWait wait;
public Dimension size;
public String destDir;
public DateFormat dateFormat;
public (swipe) {
};
public (takeScreenShot) {
};
@BeforeMethod
public void setup () throws MalformedURLException {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "My tab");
caps.setCapability("udid", "ce12182cabcaaa27017e"); //Give Device ID of your mobile phone/name of the device
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "8.1.0");
caps.setCapability("skipUnlock","true");
caps.setCapability("appPackage", "com.verizon.launcher.sdnasit");
caps.setCapability("appActivity", "com.verizon.launcher.webview.WebActivity");
caps.setCapability("noReset", "true");
driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"),caps);
wait = new WebDriverWait(driver, 10);
}
@Test
public void test () throws Exception {
//Test commands
}
@AfterMethod
public void teardown(){
driver.quit();
}
/*public AndroidDriver<AndroidElement> Capabilities() throws MalformedURLException {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "My tab");
caps.setCapability("udid", "ce12182cabcaaa27017e"); //Give Device ID of your mobile phone/name of the device
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "8.1.0");
caps.setCapability("skipUnlock","true");
caps.setCapability("appPackage", "com.verizon.launcher.sdnasit");
caps.setCapability("appActivity", "com.verizon.launcher.webview.WebActivity");
caps.setCapability("noReset", "true");
AndroidDriver<AndroidElement> driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), caps);
return driver;
wait = new WebDriverWait(driver, 10);*/
}
引用日志错误说:原始错误:无法启动com.verizon.launcher.sdnasit应用程序。
。我认为发生这种情况是因为应用程序
功能误导。
caps.setCapability("appPackage", "com.verizon.launcher.sdnasit");
caps.setCapability("appActivity", "com.verizon.launcher.webview.WebActivity");
也许这才是真正的能力:
caps.setCapability("appPackage", "com.verizon.launcher.sdnasit");
caps.setCapability("appActivity", ".webview.WebActivity");
为了确保这一点,这里介绍了如何了解appPackage
和appActivity
。
1-首先检查appium是否正在运行。
2-如果是,你应该知道有时候ode.js不能和127.0.0.1:4723说话,所以用0.0.0.0:4723代替。请记住在代码(DesiredCapability)和appium设置中更改此选项。
3-您应该保持如下代码结构。还需要使用这3种符号:(@beforethod、@Test、@AfterMethod)
大概是这样的:
import <...>
.
.
public class sample { //this is the main class. You shouldn't define it as static or void so you must not have main methode
//define variables you will be use during the test
public AndroidDriver<MobileElement> driver;
public WebDriverWait wait;
public Dimension size;
public String destDir;
public DateFormat dateFormat;
.
.
.
//define the methodes you will be use during the test
public (swipe) {
... };
public (takeScreenShot) {
...};
@BeforeMethod
public void setup () throws MalformedURLException {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "Galaxy S7 API 26");
caps.setCapability("udid", "ce0217124184c72505"); //DeviceId from "adb devices" command
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "8.0");
caps.setCapability("skipUnlock","true");
caps.setCapability("appPackage", "app_packageName"); // Your app packageName
caps.setCapability("appActivity","app_first_activity"); // The first activity of app. You can use "Apk Info2" application to find this
caps.setCapability("noReset","false");
driver = new AndroidDriver<MobileElement>(new URL("http://0.0.0.0:4723/wd/hub"),caps);
wait = new WebDriverWait(driver, 10);
}
@Test
public void test () throws Exception {
//Test commands
}
@AfterMethod
public void teardown(){
driver.quit();
}
我希望这有帮助。
问题内容: 我需要从自己的Java程序中运行其他几个程序,基本上我需要运行这些命令行语句。 和 并且我需要在自己的程序中使用从这些程序写入控制台的文本输出。我已经尝试过使用svn运行Runtime.getRuntime()。exec(),但是它似乎没有做任何事情,因为它没有生成svn.log文件。同样,两个程序都需要在不同的地方调用,svn行需要从一个文件夹内调用,而java行需要从另一文件夹内调
我使用: Appium 1.13.0 如果我试图通过手机上的Appium启动应用程序,则出现错误: 处理命令时发生未知的服务器端错误。原始错误:无法启动'name'应用程序。请访问https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md进行故障排除。
试图使用Appium(Java)在android设备上自动化本机应用程序,但遇到了以下错误: 线程"main"中的异常java.lang.NoClassDefFoundError: org/openqa/selenium/远程/内部/JsonToWebElementConverter atwibu.main(wibu.java:21) 原因:java.lang.ClassNotFoundExcep
我在android设备上构建代码时出错。这是错误报告 致命异常:AsyncTask#1进程:com。实例冈图,PID:1248爪哇。lang.RuntimeException:在android上执行doInBackground()时出错。操作系统。异步任务3美元。在java上完成(AsyncTask.java:304)。util。同时发生的未来任务。在java完成(FutureTask.java:
问题内容: 我的示例代码如下: 我的要求是,在捕获到异常之后,我要处理数组的其余元素。我怎样才能做到这一点? 问题答案: 您的代码应如下所示:
以下是包含在Apache中的没有专门手册页的简单支持程序,这些程序不是自动安装的,而是在配置过程以后,装在"support"目录下的。 log_server_status 此perl脚本可以由频繁使用的诸如cron的工具所调用。它连接到服务器并下载状态信息,并格式化此信息为一行,并记录在一个文件中。要指定结果的输出文件的位置,可以调整该脚本首行中的变量。 split-logfile 此perl脚本