簡體   English   中英

android模擬器在運行selenium腳本時掛起

[英]android emulator hangs while running selenium script

我正在使用selenium來測試一個Android網絡應用程序。 我的測試最初運行良好,但在特定點掛起。 它選擇網頁上的第一個文本字段,並在放大模式下寫入值,但此時它會掛起,而不會選擇第二個文本字段。 我哪里錯了?

我的代碼如下:

public void testRegister()throws Exception {

            driver.get("file:///android_asset/www/aboutus.html");
    driver.findElement(By.xpath("html/body/div/div/ul/li[2]")).click();
    List<WebElement> w1=driver.findElements(By.tagName("input"));
    System.out.println(w1.size());
    for(int i=0;i<w1.size();i++)
    {
    System.out.println("************");
          System.out.println(i + w1.get(i).getAttribute("id") +"*****" + w1.get(i).getAttribute("name"));

    }

    for(WebElement option:w1)
    {
          String str=option.getAttribute("id");

          if(str.equals("name"))
          {
                 option.click();
                 option.sendKeys("Vaishali");
          }

          else if(str.equals("dateofbirth"))
          {
                 option.click();
                 option.sendKeys("28-09-1991");
          }

          else if(str.equals("club"))
          {
                 option.click();
                 option.sendKeys("Manchester United");
          }

          else if(str.equals("username"))
          {
                 option.click();
                 option.sendKeys("vishchan");
          }
          else if(str.equals("password"))
          {
                 option.click();
                 option.sendKeys("vishchan");
          }
          else if(str.equals("sendbutton"))
          {
                 option.click();

          }

}
  1. id可以是'',它返回null值
  2. 在元素列表中可以隱藏具有相同id的元素,更多原因請發布堆棧跟蹤。 最好的問候塔拉斯

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM