试了好多种办法,还是不行,求助社区
设置参数
capabilities.setCapability("unicodeKeyboard", true);
capabilities.setCapability("resetKeyboard", true);
WebElement loginUsr = driver.findElement(By.id(loginId));
loginUsr.click();
loginUsr.clear();
loginUsr.sendKeys("testt");
WebElement loginPwd = driver.findElement(By.id(loginPwdId));
loginPwd.click();
loginPwd.clear();
loginPwd.sendKeys("test123");
[HTTP] --> POST /wd/hub/session {"capabilities":[{"desiredCapabilities":{"appPackage":"com.mm.epass.sample","appActivity":"com.mm.epass.sample.MainActivity","platformVersions":"5.1","noSign":true,"browserName":"","unicodeKeyboard":true,"platformName":"Android","deviceName":"M95QACP4KTFE5","resetKeyboard":true}},{"requiredCapabilities":{}}],"desiredCapabilities":{"appPackage":"com.mm.epass.sample","appActivity":"com.mm.epass.sample.MainActivity","platformVersions":"5.1","noSign":true,"browserName":"","unicodeKeyboard":true,"platformName":"Android","deviceName":"M95QACP4KTFE5","resetKeyboard":true},"requiredCapabilities":{}}
["-P",5037,"-s","9184b4a3","shell","input","keyevent","67","112","67","112","67","112","67","112","67","112"]
[debug] [MJSONWP] Responding to client with driver.clear() result: null
[HTTP] <-- POST /wd/hub/session/9eb24dd7-1898-42f3-a08d-57623c90038b/element/3/clear 200 4065 ms - 76
[HTTP] --> POST /wd/hub/session/9eb24dd7-1898-42f3-a08d-57623c90038b/element/3/value {"id":"3","value":["testt"]}
[debug] [MJSONWP] Calling AppiumDriver.setValue() with args: [["testt"],"3","9eb24dd7-1898-42f3-a08d-57623c90038b"]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:setText","params":{"elementId":"3","text":"testt","replace":false,"unicodeKeyboard":true}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:setText","params":{"elementId":"3","text":"testt","replace":false,"unicodeKeyboard":true}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: setText
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using element passed in: 3
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Attempting to clear using UiObject.clearText().
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Text remains after clearing, but it appears to be hint text.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Text not cleared. Assuming remainder is hint text.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Sending plain text to element: testt
[HTTP] <-- POST /wd/hub/session/9eb24dd7-1898-42f3-a08d-57623c90038b/element/3/value - - ms - -
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [MJSONWP] Responding to client with driver.setValue() result: true
[HTTP] --> POST /wd/hub/session/9eb24dd7-1898-42f3-a08d-57623c90038b/element/3/value {"id":"3","value":["testt"]}
[debug] [MJSONWP] Calling AppiumDriver.setValue() with args: [["testt"],"3","9eb24dd7-1898-42f3-a08d-57623c90038b"]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:setText","params":{"elementId":"3","text":"testt","replace":false,"unicodeKeyboard":true}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:setText","params":{"elementId":"3","text":"testt","replace":false,"unicodeKeyboard":true}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: setText
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using element passed in: 3
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Attempting to clear using UiObject.clearText().
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Clearing text not successful. Attempting to clear by selecting all and deleting.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Clearing text not successful. Attempting to clear by sending delete keys.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Text remains after clearing, but it appears to be hint text.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Text not cleared. Assuming remainder is hint text.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Sending plain text to element: testt
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [MJSONWP] Responding to client with driver.setValue() result: true
[HTTP] <-- POST /wd/hub/session/9eb24dd7-1898-42f3-a08d-57623c90038b/element/3/value 200 16864 ms - 76
[HTTP] --> POST /wd/hub/session/9eb24dd7-1898-42f3-a08d-57623c90038b/element {"using":"id","value":"com.meituan.epassport.sample:id/biz_tv_password"}
[debug] [MJSONWP] Calling AppiumDriver.findElement() with args: ["id","com.meituan.epassport.sample:id/biz_tv_password","9eb24dd7-1898-42f3-a08d-57623c90038b"]
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[debug] [BaseDriver] Waiting up to 20000 ms for condition
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.meituan.epassport.sample:id/biz_tv_password","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.meituan.epassport.sample:id/biz_tv_password","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.meituan.epassport.sample:id/biz_tv_password' using 'ID' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.meituan.epassport.sample:id/biz_tv_password]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":{"ELEMENT":"4"}}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"4"}
[HTTP] <-- POST /wd/hub/session/9eb24dd7-1898-42f3-a08d-57623c90038b/element 200 593 ms - 87
[HTTP] --> POST /wd/hub/session/9eb24dd7-1898-42f3-a08d-57623c90038b/element/4/clear {"id":"4"}
[debug] [MJSONWP] Calling AppiumDriver.clear() with args: ["4","9eb24dd7-1898-42f3-a08d-57623c90038b"]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:getText","params":{"elementId":"4"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:getText","params":{"elementId":"4"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getText
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":""}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:click","params":{"elementId":"4"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"4"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: click
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [ADB] Clearing up to 100 characters
[debug] [ADB] Getting connected devices...
//设置启动参数
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("unicodeKeyboard", true);
capabilities.setCapability("resetKeyboard", true);
capabilities.setCapability("noSign", true);
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "M95QACP4KTFE5");
capabilities.setCapability("platformVersions", "5.1");
//capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.mm.epass.sample");
capabilities.setCapability("appActivity", "com.mm.epass.sample.MainActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
capabilities.setCapability("noReset", true);
capabilities.setCapability("sessionOverride", true);
// 设置隐式等待超时时间
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
Thread.sleep(10000);
不行呀,试了好几次
弄好了吗,我也是试了好多种方法,每次输入后,自动删除一部分,光标移到最左边再自动输入,无语