简体   繁体   English

如何在Robotium中从Android KeyBoard(虚拟)键入Chars

[英]How to Type Chars From Android KeyBoard(Virtual) in Robotium

please give any suggestion except than solo.clickOnText(). 除了solo.clickOnText()之外,请提供任何建议。 It doesn't work. 它不起作用。

and also I don't want to use enterText() either, as that is not a good alternative. 而且我也不想使用enterText(),因为这不是一个好的选择。

[1] type " a " on text box [1]在文本框中键入“a”

[2] solo.sendKey(97); [2] solo.sendKey(97); // here 97 is ascii key code of character " a ". //这里97是字符“a”的ascii键代码。

Here i represent a nice example. 在这里我代表一个很好的例子。

public void testAutomation_typetext()
{

    solo.clickOnEditText(0);
    ch_array = "ashtemp123@gmail.com".toCharArray();
    for(int i=0;i<ch_array.length;i++) 
    {
      solo.sendKey( fun_get_android_keycode(ch_array[i]) );
    }
}


  public int fun_get_android_keycode(char ch)
  {  
       int keycode = ch;//String.valueOf(ch).codePointAt(0);
       Log.v(TAG,"in fun : "+ch+" : "+keycode + "");

       if(keycode>=97 && keycode <=122)
       {
           Log.v(TAG,"atoz : "+ch+" : "+keycode + " : " + (keycode-68));
           return keycode-68;   
       }
       else if(keycode>=65 && keycode <=90)
       {
           Log.v(TAG,"atoz : "+ch+" : "+keycode + " : " + (keycode-36));
           return keycode-36;   
       }
       else if(keycode>=48 && keycode <=57)
       {
           Log.v(TAG,"0to9"+ch+" : "+keycode + " : " + (keycode-41));
           return keycode-41;   
       }
       else if(keycode==64)
       {
           Log.v(TAG,"@"+ch+" : "+keycode + " : " + "77");
           return KeyEvent.KEYCODE_AT;
       }
       else if(ch=='.')
       {
           Log.v(TAG,"DOT "+ch+" : "+keycode + " : " + "158");
           return KeyEvent.KEYCODE_PERIOD;
       }
       else if(ch==',')
       {
           Log.v(TAG,"comma "+ch+" : "+keycode + " : " + "55");
           return KeyEvent.KEYCODE_COMMA;
       }
       return 62;
}   

i hope this will help in your best automation test case. 我希望这对您最好的自动化测试案例有所帮助。 Thanks. 谢谢。

You can't do that for now. 你现在不能这样做。 See http://code.google.com/p/robotium/wiki/QuestionsAndAnswers and look for Keyboard. 请参阅http://code.google.com/p/robotium/wiki/QuestionsAndAnswers并查找键盘。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从Android虚拟设备上的控制台进行的Robotium测试无法正常工作 - Robotium tests from console on android virtual device are not working Robotium可以使用android虚拟键盘中小于(&lt;)按钮的键码值(自动化) - keycode value for less than(<) button in android virtual keyboard can be used by Robotium(automation) 如何从屏幕(虚拟)键盘上获得压力? (机器人) - How to get pressure from on screen (Virtual) keyboard? (Android) 如何防止虚拟键盘打开 Nativescript (IOS/Android) - How to prevent the virtual keyboard from opening Nativescript (IOS/Android) Android:阻止虚拟键盘上的按键 - Android: Blocking keys from virtual keyboard 如何在Android上使用Robotium测试从列表中删除项目 - How to Test removing item from the list using Robotium on Android 如何在Android上的Flash游戏中使用虚拟键盘? - How to use a virtual keyboard for flash game on android? 如何验证Android虚拟键盘上的键? - How to validate keys on the virtual keyboard on Android? 如何使用Delphi在Android中检测虚拟键盘事件 - How to detect Virtual Keyboard Events in Android with Delphi 如何在虚拟键盘上打开 Android 模拟器上的剪贴板? - How turn on clipboard on Android emulator on virtual keyboard?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM