我如何點擊按鈕法師我 試圖與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();
您的上一個xpath似乎是正確的。在執行該命令來查找ImageButton之前,請確保您的應用程序的屏幕已完全加載。 – Vinod