本文介绍了无法通过Selenium和Java在https://spicejet.com中选择出发日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试从日历中选择一个自2018年10月31日起的出发日期" https://spicejet.com/但我收到错误消息未知错误:元素在点(832,242)不可单击.其他元素将获得单击:..."请帮帮我.这是我的代码得到这样的异常:

I am trying to select a "Depart date" as of 31st october 2018 from the calender https://spicejet.com/ But I am getting error "unknown error: Element is not clickable at point (832, 242). Other element would receive the click: ..." Please help me out. Here is my code getting such exception:

public class bookflight extends Thread {

    UtilityMethods utilObj= new UtilityMethods();
    @Test
    public void SighnUp() throws IOException
    {
        utilObj.getdriver().get("https://spicejet.com");
        utilObj.getdriver().manage().window().maximize();

        utilObj.getdriver().findElement(By.id("ctl00_mainContent_ddl_originStation1_CTXT")).click();
        utilObj.getdriver().findElement(By.xpath("//a[contains(text(),'Guwahati (GAU)')]")).click();
        utilObj.getdriver().findElement(By.xpath("//a[contains(text(),'Goa (GOI)')]")).click();
        utilObj.getdriver().findElement(By.className("ui-datepicker-trigger")).click();
        utilObj.getdriver().findElement(By.xpath("//div[@class='ui-datepicker-group ui-datepicker-group-first'])/parent:://table[@class='ui-datepicker-calendar']following-sibling::./a/contains(text(),'31')")).click();
    }
}

推荐答案

要选择来自(例如 Guwahati(GAU)), (例如 Goa(GOI))目的地和 DEPART DATE 作为 url https://spicejet.com/中的 31/10 需要诱使 WebDriverWait 使所需的元素可点击,您可以使用以下解决方案:

To select From (e.g. Guwahati(GAU)), To (e.g. Goa(GOI)) destination and DEPART DATE as 31/10 within the url https://spicejet.com/ you need to induce WebDriverWait for the desired element to be clickable and you can use the following solution:

  • 代码块:

  • Code Block:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class spicejet_login {

    public static void main(String[] args) {


        System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");
        WebDriver driver = new FirefoxDriver();
        driver.get("https://spicejet.com");
        new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@id='ctl00_mainContent_ddl_originStation1_CTXT']"))).click();
        driver.findElement(By.xpath("//div[@id='glsctl00_mainContent_ddl_originStation1_CTNR']//table[@id='citydropdown']//li/a[@value='GAU']")).click();
        driver.findElement(By.xpath("//div[@id='ctl00_mainContent_ddl_destinationStation1_CTNR']//table[@id='citydropdown']//li/a[@value='GOI']")).click();
        new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//table[@class='ui-datepicker-calendar']//tr//a[contains(@class,'ui-state-default') and contains(.,'31')]"))).click();
    }
}

  • 浏览器快照:

  • Browser Snapshot:

    这篇关于无法通过Selenium和Java在https://spicejet.com中选择出发日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 06-27 06:31