2 回答

TA貢獻1810條經驗 獲得超4個贊
檢查元素是否在框架內如果是 - 然后 - 首先選擇框架 -
Select Frame name or id of iframe
然后執行以下操作 -
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath(".//a[@ng-show='canCreate']"))).click();
如果沒有框架那么你可以直接與元素交互 -
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath(".//a[@ng-show='canCreate']"))).click();

TA貢獻1757條經驗 獲得超7個贊
您需要添加顯式等待條件,尤其是在處理包含 Angular JS 元素的頁面時
WebElement newStudyEnrollment= driver.findElement(By.xpath("//a[contains(text(),'New
Study Enrollment')]"));
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.elementToBeClickable(newStudyEnrollment));
newStudyEnrollment.click();
添加回答
舉報