无法单击图像按钮

时间:2017-06-05 12:37:50

标签: appium android-uiautomator

enter image description here

我如何点击法师按钮 我试过xpath和id下面是我试过的提到的代码     driver.findElementById(" btn_google&#34)。单击(); // driver.findElementByName("使用Google +&#34登录;)。click();         //driver.findElementByXPath(" ;//android.widget.ImageButton[@content-desc='使用Google +',@ resource-id,' btn_google']登录"。)点击();     // driver.findElementByXPath(" // android.widget.Button [contains(@ resource-id,' btn_google')和@ content-desc,'使用Google +登录&# 39;]&#34)点击();

//  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 [@ resource-id =' com.zipgo.customer:id / btn_google']" ); // googlebutton.click();

2 个答案:

答案 0 :(得分:0)

您只需找到该图像按钮的 Transition t = new Fade(); // Inflating a transition from /transition/my_transition.xml // t = TransitionInflater.from(this).inflateTransition(R.transition.my_transition); // If transition is set through theme via `android:windowExitTransition` // t = getWindow().getExitTransition(); // Adding a target // t.addTarget(rootView); // Excluding decorView, which will exclude all children too t.excludeTarget(getWindow().getDecorView(), true); t.excludeTarget(android.R.id.statusBarBackground, true); t.excludeTarget(android.R.id.navigationBarBackground, true); getWindow().setExitTransition(t); ,如:

id

现在你可以为任何操作调用一个监听器方法,例如:

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

答案 1 :(得分:0)

试试这个

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