Appium 无法单击图像按钮

Appium 无法单击图像按钮,appium,android-uiautomator,Appium,Android Uiautomator,如何点击法师按钮 我试过使用xpath,下面是我试过的代码 driver.findElementById(“btn_google”)。单击(); //findElementByName(“使用Google+登录”)。单击(); //driver.findelementbypath(“//android.widget.ImageButton[@content desc='Login with Google+',@resource id,'btn_Google'])。单击(); //driver.f

如何点击法师按钮 我试过使用xpath,下面是我试过的代码 driver.findElementById(“btn_google”)。单击(); //findElementByName(“使用Google+登录”)。单击(); //driver.findelementbypath(“//android.widget.ImageButton[@content desc='Login with Google+',@resource id,'btn_Google'])。单击(); //driver.findelementbypath(//android.widget.Button[包含(@resource id,'btn_google')和@content desc,'Login with google+'])。单击()

//WebElement googlebutton=driver.findelementbypath(“//android.widget.ImageButton[@resource id='com.zipgo.customer:id/btn_google']);
//Google按钮。单击()

您只需找到该图像按钮的
id
,如下所示:

googleImageButton=(ImageButton)findViewById(R.id.googleImageButton);
现在您可以为任何操作调用侦听器方法,例如:

googleImageButton.setOnClickListener(googleImageButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               //action
            }
        });)
试试这个


driver.findelementbypath(“//android.widget.ImageButton[@index='0'])。单击()这是程序员在构建本机应用程序时所做的,从测试人员的角度来看,我无法单击bimage按钮您的最后一个xpath似乎是正确的。在执行查找ImageButton的命令之前,请确保应用程序的屏幕已完全加载。
googleImageButton.setOnClickListener(googleImageButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               //action
            }
        });)