千巷猫影
要处理动态元素,请引入WebDriverWait并等待元素elementToBeClickable然后单击。试试下面的代码。WebDriverWait wait = new WebDriverWait(driver, 30);WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class='fr mt-header']/a[@class='registrationBtn' and @title='Client-Patient Registration']")));element.click()或者WebDriverWait wait = new WebDriverWait(driver, 30);WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class='fr mt-header']/a[@class='registrationBtn' and @title='Client-Patient Registration']/span[@class='reg_icon']")));element.click()