简体   繁体   English

无法使用Selenium WebDriver单击继续付款按钮

[英]Unable to click on proceed to payment button using selenium webdriver

driver.findElement(By.className("pull-right"));
WebElement payment_button =  driver.findElement(By.xpath("//*[contains(text(), 'Proceed To Payment')]"));
          payment_button.click();

Here's a link to the page . 这是该页面链接

Error message at console: 控制台上的错误消息:

Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: element not visible

Waiting for iframe to be visible and also button to be visible before interacting with it 与iframe互动之前,等待iframe可见并且按钮也可见

    driver.get("https://www.vipcars.com/search-new/?aff=vipcar&language=en&pickup_country=441&pickup_city=9747&pickup_location=14927&dropoff_country=441&dropoff_city=9747&dropoff_location=14927&pickup_date=2016-10-28&pickup_time=10:00&dropoff_date=2016-10-29&dropoff_time=10:00&rc=in_1&driver_age=29&currency=INR&show_multilingual=1&custom_css=aHR0cHM6Ly93d3cudmlwY2Fycy5jb20vY29tbW9uL2Nzcy9uZXdmb3JtLmNzcw==&step2url=aHR0cHM6Ly93d3cudmlwY2Fycy5jb20vc2VhcmNoLW5ldy8=&terms_page=aHR0cHM6Ly93d3cudmlwY2Fycy5jb20vdGVybXNfY29uZGl0aW9ucw==&googlemap=1&page=book&car_id=10067709");

new WebDriverWait(driver, 5).until(ExpectedConditions.visibilityOfElementLocated(By.id("supplycarsIframe")));
                                driver.switchTo().frame(driver.findElement(By.id("supplycarsIframe")));

new WebDriverWait(driver, 5).until(ExpectedConditions.visibilityOfElementLocated(By.id("proceeed_to_payment")));

WebElement procPay = driver.findElement(By.id("proceeed_to_payment"));

System.out.println(procPay.getText());

driver.switchTo().defaultContent();

try once with below code 用下面的代码尝试一次

d1.switchTo().frame("supplycarsIframe");
d1.findElement(By.xpath("//button[@class='subMitBtnInc ProcPay'][@id='proceeed_to_payment']")).click();
d1.switchTo().defaultContent();

您需要在等待所有内容加载后向下滚动,以使按钮真正可见,然后您才能单击它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM