HTML:
<a href="https://stgtest.flexforceondemand.com/associateregistration/consenttoproceed?bid=U20xNFozbFBkV0pFZWpWWlpGRjRVMUZJZUVwWFFUMDlPanBnTHhJRmY4R1VRWVh6aFVHN2swcW0%2A&zc=VkdSdVVGZHRTbEZVY3pkWFRYZGFkRTVTUVhFclp6MDlPanJFTUVSazZNV0ErYTdlZ0ovR1BhWng%2A" class="btn btn-success btn-lg">Apply Now</a>
我已经尝试过以下操作:
driver.findElement(By.xpath("//a[text()='Apply Now']")).click();
driver.findElement(By.xpath("(.//[@href='Apply Now'])")).click();
driver.findElement(By.xpath("//a[@href='Apply Now']")).click();
driver.findElement(By.linkText("Apply Now")).click();
driver.findElement(By.className("Apply Now")).click();
driver.findElement(By.xpath("//div[contains(@class,'btn btn-success btn-lg')]")).click();
driver.findElement(By.xpath("//div[contains(@class,'btn btn-success btn-lg')]")).click();v
最佳答案
尝试使用 Webdriver 单击,等待元素正确加载到 Dom
中并准备好接收单击
。
WebDriverWait wait = new WebDriverWait(driver, 40);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[.='Apply Now']"))).click();
关于java - 如何点击“立即申请”按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60016996/