我正在eBay android应用程序上执行自动化测试。首先,我需要在eBay中自动登录然后我想继续结帐。
我能够在eBay中自动登录,除了一个按钮,即 SIGN IN (此按钮将用户重定向到登录屏幕)。所有其他按钮单击正在运行,但单击“登录”按钮不起作用。
这是我的代码。
private static void executeLoginFlow() {
// This is not working
MobileElement loginButton = ((AndroidDriver<MobileElement>) driver)
.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.ebay.mobile:id/button_sign_in\")");
loginButton.click();
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// This is working
MobileElement emailEditText = ((AndroidDriver<MobileElement>) driver).findElementByAndroidUIAutomator(
"new UiSelector().resourceId(\"com.ebay.mobile:id/edit_text_username\")");
emailEditText.clear();
emailEditText.setValue("abc@xyz.com");
driver.hideKeyboard();
((AndroidDriver<MobileElement>) driver).pressKeyCode(66);
// // This is working
MobileElement passwordEditText = ((AndroidDriver<MobileElement>) driver).findElementByAndroidUIAutomator(
"new UiSelector().resourceId(\"com.ebay.mobile:id/edit_text_password\")");
passwordEditText.clear();
passwordEditText.setValue("123456789");
driver.hideKeyboard();
// This also working
MobileElement mainLoginButton = ((AndroidDriver<MobileElement>) driver)
.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.ebay.mobile:id/button_sign_in\")");
mainLoginButton.click();
}
我正在使用 java-client-5.0.0.jar 。