Appium不使用数字键盘

时间:2018-05-16 10:04:14

标签: testing keyboard numeric appium-android

我正在尝试在编辑字段中输入数字,虽然该字段是聚焦的,但Appium无法输入字符。我已经尝试过多种方式,但都没有用。

示例1:

2018-05-16 15:26:45,696 ERROR o.a.j.JMeter: Uncaught exception: 
java.lang.NoClassDefFoundError: Could not initialize class org.apache.jmeter.testbeans.gui.GenericTestBeanCustomizer

at org.apache.jmeter.testbeans.BeanInfoSupport.createPropertyGroup(BeanInfoSupport.java:255) ~[ApacheJMeter_core.jar:4.0 r1823414]

at org.apache.jmeter.config.CSVDataSetBeanInfo.<init>(CSVDataSetBeanInfo.java:58) ~[ApacheJMeter_components.jar:4.0 r1823414]

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_25]

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_25]

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_25]

at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_25]

at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_25]
    at com.sun.beans.finder.InstanceFinder.instantiate(Unknown Source) ~[?:1.8.0_25]

    at com.sun.beans.finder.InstanceFinder.find(Unknown Source) ~[?:1.8.0_25]

at java.beans.Introspector.findExplicitBeanInfo(Unknown Source) ~[?:1.8.0_25]

at java.beans.Introspector.<init>(Unknown Source) ~[?:1.8.0_25]

at java.beans.Introspector.getBeanInfo(Unknown Source) ~[?:1.8.0_25]

at org.apache.jmeter.testbeans.TestBeanHelper.prepare(TestBeanHelper.java:66) ~[ApacheJMeter_core.jar:4.0 r1823414]

at org.apache.jmeter.threads.TestCompiler.trackIterationListeners(TestCompiler.java:183) ~[ApacheJMeter_core.jar:4.0 r1823414]

at org.apache.jmeter.threads.TestCompiler.subtractNode(TestCompiler.java:137) ~[ApacheJMeter_core.jar:4.0 r1823414]

at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:998) ~[jorphan.jar:4.0 r1823414]

at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:995) ~[jorphan.jar:4.0 r1823414]

at org.apache.jorphan.collections.HashTree.traverse(HashTree.java:977) ~[jorphan.jar:4.0 r1823414]

at org.apache.jmeter.threads.JMeterThread.initRun(JMeterThread.java:611) ~[ApacheJMeter_core.jar:4.0 r1823414]

at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:246) ~[ApacheJMeter_core.jar:4.0 r1823414]

at java.lang.Thread.run(Unknown Source) [?:1.8.0_25]
2018-05-16 15:26:45,712 INFO o.a.j.t.JMeterThread: Thread finished: Users 1-1157
2018-05-16 15:26:45,712 ERROR o.a.j.JMeter: Uncaught exception: 
java.lang.NoClassDefFoundError: Could not initialize class org.apache.jmeter.testbeans.gui.GenericTestBeanCustomizer

at org.apache.jmeter.testbeans.BeanInfoSupport.createPropertyGroup(BeanInfoSupport.java:255) ~[ApacheJMeter_core.jar:4.0 r1823414]

at org.apache.jmeter.config.CSVDataSetBeanInfo.<init>(CSVDataSetBeanInfo.java:58) ~[ApacheJMeter_components.jar:4.0 r1823414]

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_25]

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_25]

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_25]

at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_25]

at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_25]
    at com.sun.beans.finder.InstanceFinder.instantiate(Unknown Source) ~[?:1.8.0_25]

    at com.sun.beans.finder.InstanceFinder.find(Unknown Source) ~[?:1.8.0_25]

at java.beans.Introspector.findExplicitBeanInfo(Unknown Source) ~[?:1.8.0_25]

at java.beans.Introspector.<init>(Unknown Source) ~[?:1.8.0_25]

at java.beans.Introspector.getBeanInfo(Unknown Source) ~[?:1.8.0_25]

at org.apache.jmeter.testbeans.TestBeanHelper.prepare(TestBeanHelper.java:66) ~[ApacheJMeter_core.jar:4.0 r1823414]

at org.apache.jmeter.threads.TestCompiler.trackIterationListeners(TestCompiler.java:183) ~[ApacheJMeter_core.jar:4.0 r1823414]

    at org.apache.jmeter.threads.TestCompiler.subtractNode(TestCompiler.java:137) ~[ApacheJMeter_core.jar:4.0 r1823414]

at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:998) ~[jorphan.jar:4.0 r1823414]

at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:995) ~[jorphan.jar:4.0 r1823414]

    at org.apache.jorphan.collections.HashTree.traverse(HashTree.java:977) ~[jorphan.jar:4.0 r1823414]

at org.apache.jmeter.threads.JMeterThread.initRun(JMeterThread.java:611) ~[ApacheJMeter_core.jar:4.0 r1823414]

at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:246) ~[ApacheJMeter_core.jar:4.0 r1823414]

at java.lang.Thread.run(Unknown Source) [?:1.8.0_25]
2018-05-16 15:26:45,790 ERROR o.a.j.JMeter: Uncaught exception: 
java.lang.UnsatisfiedLinkError: C:\Program Files (x86)\Java\jre1.8.0_25\bin\awt.dll: ”ÛH`ÚH¼ÖH—‹„G¶

at java.lang.ClassLoader$NativeLibrary.load(Native Method) ~[?:1.8.0_25]

at java.lang.ClassLoader.loadLibrary0(Unknown Source) ~[?:1.8.0_25]

at java.lang.ClassLoader.loadLibrary(Unknown Source) ~[?:1.8.0_25]

at java.lang.Runtime.loadLibrary0(Unknown Source) ~[?:1.8.0_25]
    at java.lang.System.loadLibrary(Unknown Source) ~[?:1.8.0_25]

at java.awt.Toolkit$3.run(Unknown Source) ~[?:1.8.0_25]
    at java.awt.Toolkit$3.run(Unknown Source) ~[?:1.8.0_25]

at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_25]

at java.awt.Toolkit.loadLibraries(Unknown Source) ~[?:1.8.0_25]
    at java.awt.Toolkit.<clinit>(Unknown Source) ~[?:1.8.0_25]

at java.awt.Component.<clinit>(Unknown Source) ~[?:1.8.0_25]

at org.apache.jmeter.testbeans.BeanInfoSupport.createPropertyGroup(BeanInfoSupport.java:255) ~[ApacheJMeter_core.jar:4.0 r1823414]

at org.apache.jmeter.config.CSVDataSetBeanInfo.<init>(CSVDataSetBeanInfo.java:58) ~[ApacheJMeter_components.jar:4.0 r1823414]

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_25]

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_25]

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_25]

at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_25]

at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_25]

at com.sun.beans.finder.InstanceFinder.instantiate(Unknown Source) ~[?:1.8.0_25]

at com.sun.beans.finder.InstanceFinder.find(Unknown Source) ~[?:1.8.0_25]

at java.beans.Introspector.findExplicitBeanInfo(Unknown Source) ~[?:1.8.0_25]

at java.beans.Introspector.<init>(Unknown Source) ~[?:1.8.0_25]
    at java.beans.Introspector.getBeanInfo(Unknown Source) ~[?:1.8.0_25]

at org.apache.jmeter.testbeans.TestBeanHelper.prepare(TestBeanHelper.java:66) ~[ApacheJMeter_core.jar:4.0 r1823414]

at org.apache.jmeter.threads.TestCompiler.trackIterationListeners(TestCompiler.java:183) ~[ApacheJMeter_core.jar:4.0 r1823414]

at org.apache.jmeter.threads.TestCompiler.subtractNode(TestCompiler.java:137) ~[ApacheJMeter_core.jar:4.0 r1823414]

at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:998) ~[jorphan.jar:4.0 r1823414]

at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:995) ~[jorphan.jar:4.0 r1823414]

at org.apache.jorphan.collections.HashTree.traverse(HashTree.java:977) ~[jorphan.jar:4.0 r1823414]

at org.apache.jmeter.threads.JMeterThread.initRun(JMeterThread.java:611) ~[ApacheJMeter_core.jar:4.0 r1823414]

at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:246) ~[ApacheJMeter_core.jar:4.0 r1823414]

at java.lang.Thread.run(Unknown Source) [?:1.8.0_25]
2018-05-16 15:26:45,805 INFO o.a.j.t.JMeterThread: Thread finished: Users 1-990
2018-05-16 15:26:45,805 ERROR o.a.j.JMeter: Uncaught exception: 

示例2:

driver.FindElementByXPath("field_to_fill").SendKeys("value");

该字段是EditText字段,Android平台版本:7.0,我使用C#。

2 个答案:

答案 0 :(得分:1)

年龄较大,但这也许将来会对某人有所帮助。在被测试的应用程序从qwerty键盘更改为数字键盘后,我昨天遇到了这个问题。 (在Java中)我最初使用的是driver.sendKeys(stringOfDigits),它与数字键盘的显示不符。 driver.setValue(stringOfDigits)driver.pressKey(new KeyEvent(AndroidKey.NUMPAD_0));都不起作用。

我发现driver.pressKey(new KeyEvent(AndroidKey.DIGIT_0));有效。或者在我的情况下,我是从字符串中输入一组数字,所以我使用了循环:

for(char c : stringOfDigits.toCharArray()) {
  driver.pressKey(new KeyEvent(AndroidKey.valueOf("DIGIT_" + c)));
}

我通常使用C#,但是该项目使用Java。希望两种语言的Appium都一样。

答案 1 :(得分:0)

我在java上有类似的问题,所以我使用了两种方法来解决:

<强> 1.method   - 点击textField()   - 获取UIAKeyboard的pageobject,覆盖numpad键盘(将所有按钮提取到页面对象中)   - 在pageobject中使用脚本方法单击Number元素。按名称。

<强> 2.method   - 发送密钥代码(尝试使用本机驱动程序AndroidDriver而不是MobileDriver)

第3。方法

driver.sendkeyEvent(int key);

密钥代码列表:

a - z-> 29 - 54
"0" - "9"-> 7 - 16 
BACK BUTTON - 4, 
MENU BUTTON - 82 
UP-19, 
DOWN-20,
LEFT-21, 
IGHT-22 
SELECT (MIDDLE) BUTTON - 23 
SPACE - 62, 
SHIFT - 59,
ENTER - 66,
BACKSPACE - 67

或更新版本

driver.pressKeyCode(AndroidKeyCode.HOME);

<强> 4。方法(没有经过测试) 使用x,y坐标为每个数字(0-9&amp ;.)和使用的driver.tap方法