无法使用selenium webdriver点击进入付款按钮

时间:2016-10-19 11:16:56

标签: java selenium

cat

这是link to the page

控制台上的错误消息:

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

3 个答案:

答案 0 :(得分:0)

等待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();

答案 1 :(得分:0)

使用以下代码尝试一次

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

答案 2 :(得分:0)

你需要在等待加载所有内容后向下滚动,这样按钮实际上是可见的,只有这样才能点击它