久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <small id='tYD6J'></small><noframes id='tYD6J'>

    <i id='tYD6J'><tr id='tYD6J'><dt id='tYD6J'><q id='tYD6J'><span id='tYD6J'><b id='tYD6J'><form id='tYD6J'><ins id='tYD6J'></ins><ul id='tYD6J'></ul><sub id='tYD6J'></sub></form><legend id='tYD6J'></legend><bdo id='tYD6J'><pre id='tYD6J'><center id='tYD6J'></center></pre></bdo></b><th id='tYD6J'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='tYD6J'><tfoot id='tYD6J'></tfoot><dl id='tYD6J'><fieldset id='tYD6J'></fieldset></dl></div>
  • <tfoot id='tYD6J'></tfoot>
        <legend id='tYD6J'><style id='tYD6J'><dir id='tYD6J'><q id='tYD6J'></q></dir></style></legend>

          <bdo id='tYD6J'></bdo><ul id='tYD6J'></ul>

        如何使用 Google UiAutomator 按兩次按鈕?

        How to press a button twice using Google UiAutomator?(如何使用 Google UiAutomator 按兩次按鈕?)

        <small id='hna96'></small><noframes id='hna96'>

        <i id='hna96'><tr id='hna96'><dt id='hna96'><q id='hna96'><span id='hna96'><b id='hna96'><form id='hna96'><ins id='hna96'></ins><ul id='hna96'></ul><sub id='hna96'></sub></form><legend id='hna96'></legend><bdo id='hna96'><pre id='hna96'><center id='hna96'></center></pre></bdo></b><th id='hna96'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='hna96'><tfoot id='hna96'></tfoot><dl id='hna96'><fieldset id='hna96'></fieldset></dl></div>

            <bdo id='hna96'></bdo><ul id='hna96'></ul>
              <tbody id='hna96'></tbody>

            • <legend id='hna96'><style id='hna96'><dir id='hna96'><q id='hna96'></q></dir></style></legend>
              <tfoot id='hna96'></tfoot>
                • 本文介紹了如何使用 Google UiAutomator 按兩次按鈕?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有以下腳本,用于在 Android 中使用 UiAutomator 在計算器中輸入33".但是,只接受第一個 '3',第二次按下完全被忽略.

                  I have the following script for typing '33' into the Calculator, in Android, using UiAutomator. However, only the first '3' is accepted, the second press is entirely ignored.

                  import com.android.uiautomator.core.*;
                  import com.android.uiautomator.testrunner.UiAutomatorTestCase;
                  
                  public class MyFirstUiAutomatorTest extends UiAutomatorTestCase {
                      UiObject getByDescription(String description) {
                          return new UiObject(new UiSelector().description(description));
                      }
                  
                      UiObject getByText(String description) {
                          return new UiObject(new UiSelector().text(description));
                      }
                  
                      UiObject scrollableGetByText(String text ) throws UiObjectNotFoundException {
                              UiScrollable uiScrollable = new UiScrollable(new UiSelector().scrollable(true));
                              uiScrollable.setAsHorizontalList();
                              return uiScrollable.getChildByText(new UiSelector().className(
                                      android.widget.TextView.class.getName()),
                                      text);      
                      }
                  
                      public void testStuff() throws UiObjectNotFoundException {
                          getUiDevice().pressHome();
                          getByDescription("Apps").clickAndWaitForNewWindow();
                          getByText("Apps").click();
                          scrollableGetByText("Calculator").clickAndWaitForNewWindow();
                  
                          // pressing '+' and '=' effectively clears the previous input
                          getByText("+").click();
                          getByText("=").click();
                          getByText("3").click();
                          // this second '3' is ignored
                          getByText("3").click();
                      }
                  }
                  

                  我嘗試在第一次點擊后添加睡眠 2 秒,方法是:

                  I've tried adding a sleep for 2 seconds after the first click, by doing:

                          try {
                              Thread.sleep(2000);
                          } catch (InterruptedException e) {
                              e.printStackTrace();
                          }
                  

                  ...但這并沒有改變任何東西.

                  ... but that didn't change anything.

                  我還嘗試在 2 個 '3' 之間單擊另一個按鈕,即:

                  I also tried clicking on a different button, in between the 2 '3's, ie:

                          new UiObject(new UiSelector().text("3")).click();
                          new UiObject(new UiSelector().className("android.widget.EditText")).click();
                          new UiObject(new UiSelector().text("3")).click();
                  

                  ...但這也沒有用.

                  想法?

                  (注意:在 AVD 中使用 Android 4.1.2;在 Ubuntu linux 12.04 上運行)

                  (Note: using Android 4.1.2, in an AVD; running on Ubuntu linux 12.04)

                  編輯,根據 Rami 的觀察,我嘗試了以下方法,以重復使用相同的 UiObject 對象來獲得相同描述的第二次請求:

                  Edit, following Rami's observations, I tried the following, to reuse the same UiObject object for a second request for the same description:

                  HashMap<String,UiObject> objectByText = new HashMap<String,UiObject>(); 
                  UiObject getByText(String description) {
                      if( objectByText.containsKey(description)) {
                          System.out.println("" + objectByText.get(description) );
                          return objectByText.get(description);
                      }
                      System.out.println("Created new object for [" + description + "]");
                      UiObject object = new UiObject(new UiSelector().text(description));
                      objectByText.put(description, object );
                      System.out.println("" + object );
                      return object;
                  }
                  

                  ...但它不起作用,即使它每次都清楚地重用同一個 UiObject,因為它只說一次為 [3] 創建新對象".

                  ... but it didn't work, even though it is clearly reusing the same UiObject each time, because it only says 'Created new object for [3]' once.

                  然后我嘗試了 UiDevice.click() 'trick',通過創建一個函數 'click' 如下,再次遵循 Rami 的觀察:

                  Then I tried the UiDevice.click() 'trick', by creating a function 'click' as follows, again, following Rami's observations:

                  void click(UiObject target ) throws UiObjectNotFoundException {
                      Rect rect = target.getBounds();
                      System.out.println("rect: " + rect );
                      getUiDevice().click(rect.centerX(), rect.centerY());
                  }
                  

                  但是,這對我也不起作用:只出現第一個3",第二個被忽略,即使兩次點擊都明顯在同一個地方,因為 rect:輸出位置相同.如果我使用自己的桌面鼠標手動單擊3"兩次,則兩個 3 都顯示正常.

                  However, this didn't work for me either: only the first '3' appears, and the second is ignored, even though both clicks are clearly in the same place, because the rect: output locations are identical. If I click '3' twice manually, using my own desktop mouse, then both 3s appear ok.

                  我還嘗試在兩次點擊之間添加兩秒 Thread.sleep(),但我仍然只出現了一個3".

                  I also tried adding a two second Thread.sleep() between the clicks, and still only a single '3' appeared for me.

                  推薦答案

                  不要只按文本搜索,而是嘗試按文本和類搜索.這是執行此操作的示例方法.

                  Instead of just searching by text, try searching by the text and the class. Here is a sample method for doing so.

                  Uiobject getByTextAndClass(String text, String className) {
                      return new UiObject(new UiSelector().text(text).className(className));
                  }
                  

                  然后,如果您嘗試為帶有數字 3 的計算器按鈕調用此方法:

                  And then if you are trying to call this method for the Calculator button with number 3 on it:

                  getByTextAndClass("3", android.widget.Button.class.getName()).click();
                  

                  您可以使用 UiAutomatorViewer 工具:{android-sdk}/tools/uiautomator.bat 查看不同 UiObject 的類名和其他屬性.

                  You can use the UiAutomatorViewer tool: {android-sdk}/tools/uiautomator.bat to check the classnames and other attributes of different UiObjects.

                  這適用于我的 4.2.2 設備,但我正在下載 4.1.2 以在那里進行測試.

                  This works on my 4.2.2 devices, but I am downloading 4.1.2 to test it on there as well.

                  我在 4.1.2 AVD 上嘗試過,它可以在我的 Windows 機器上運行.

                  I tried it on a 4.1.2 AVD and it works on my Windows machine.

                  這篇關于如何使用 Google UiAutomator 按兩次按鈕?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)
                    <tbody id='BU2sG'></tbody>
                  <tfoot id='BU2sG'></tfoot>

                  <i id='BU2sG'><tr id='BU2sG'><dt id='BU2sG'><q id='BU2sG'><span id='BU2sG'><b id='BU2sG'><form id='BU2sG'><ins id='BU2sG'></ins><ul id='BU2sG'></ul><sub id='BU2sG'></sub></form><legend id='BU2sG'></legend><bdo id='BU2sG'><pre id='BU2sG'><center id='BU2sG'></center></pre></bdo></b><th id='BU2sG'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='BU2sG'><tfoot id='BU2sG'></tfoot><dl id='BU2sG'><fieldset id='BU2sG'></fieldset></dl></div>

                        <bdo id='BU2sG'></bdo><ul id='BU2sG'></ul>
                      • <legend id='BU2sG'><style id='BU2sG'><dir id='BU2sG'><q id='BU2sG'></q></dir></style></legend>
                        • <small id='BU2sG'></small><noframes id='BU2sG'>

                            主站蜘蛛池模板: 午夜三级网站 | 天堂视频中文在线 | 日本不卡一区二区三区 | 国产h视频| 亚洲成人一二区 | 日韩一级 | 色婷婷综合网 | 免费福利视频一区二区三区 | 91日b| 国产一级片| 中文字幕一区二区三区乱码在线 | 国产精品高潮呻吟久久久久 | 色视频在线免费观看 | 日韩视频在线一区 | 午夜精品久久久久久久久久久久 | 日韩免费一二三区 | 91精品国产一区二区三区 | 国产精品色综合 | 91成人免费看| 日本不卡一区 | 欧美不卡视频 | 国产精品不卡一区 | 亚洲一区二区电影网 | 男女污污网站 | 亚洲欧洲成人av每日更新 | 国产ts一区 | 亚洲网站在线 | 中午字幕在线观看 | 久久久久久免费观看 | 91网站在线播放 | 五月激情婷婷在线 | 欧美成人精品一区 | 亚洲成人精品 | 99爱在线免费观看 | 2019天天干天天操 | 成人区一区二区三区 | 日日人人 | 亚洲精品电影网在线观看 | 日本在线小视频 | 国产馆| 日本一区二区三区在线观看 |