2017-06-05 207 views
-1

enter image description here无法点击图片按钮

我如何点击按钮法师我 试图与XPath和ID下面是我曾试图 driver.findElementById(“btn_google”)提到的代码。单击( ); // driver.findElementByName(“Login with Google +”)。click(); //driver.findElementByXPath("//android.widget.ImageButton[@content-desc='Login with Google +',@ resource-id,'btn_google']“)。click(); // driver.findElementByXPath(“// android.widget.Button [contains(@ resource-id,'btn_google')and @ content-desc,'用Google +登录']”)。click();

// driver.findElementByXPath("//*[@class='android.widget.ImageButton' and @resource-id='btn_google']").click(); 

    //driver.findElementByName("Login with Google+").click();; 
    WebElement element=driver.findElementByXPath("//*[@class='android.widget.ImageButton' and @resource-id='btn_google']"); 
    TouchAction action = new TouchAction(driver); 
    action.longPress(element).release().perform(); 

    //driver.findElement(By.xpath("//android.widget.ImageButton[@content-desct='Login with Google+']")).click(); 

// WebElement googlebutton = driver.findElementByXPath( “// android.widget.ImageButton [@资源-ID = 'com.zipgo.customer:ID/btn_google']”); // googlebutton.click();

+0

您的上一个xpath似乎是正确的。在执行该命令来查找ImageButton之前,请确保您的应用程序的屏幕已完全加载。 – Vinod

回答

0

您只需找到的id是ImageButton的,如:

googleImageButton=(ImageButton)findViewById(R.id.googleImageButton); 

现在你可以调用任何操作的监听方法,为如:

googleImageButton.setOnClickListener(googleImageButton.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       //action 
      } 
     });) 
+0

这是什么编码器做什么时,你建立一个本地应用程序,从测试者的角度来看,我不能点击那个bimage按钮 – Jagaur

0

试试这个

driver.findElementByXpath("//android.widget.ImageButton[@index='0']").click();

+0

我已经做到了这一点,谢谢你花时间 – Jagaur

+0

嘿..其实我昨天看到这..好知道 – Vijay