无法单击单选按钮

时间:2016-04-21 18:03:49

标签: selenium-webdriver click radio-button

我想点击spice jet book的单向单选按钮飞行页面.i以网页驱动程序格式编写以下代码但按钮无法点击

public void flight() throws Exception{   
        driver.get("http://www.spicejet.com/FlyForSure.aspx");
        driver.manage().window().maximize();
        WebDriverWait wait=new WebDriverWait(driver,40);
        driver.findElement(By.cssSelector("input.AvailabilitySearchInputCompactSearchVi_OneWay")).click();
}


public static void main(String[] args) throws Exception {
        // TODO Auto-generated method stub
     spice a1=new spice();
     a1.flight();
}

}

错误讯息;

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"css selector","selector":"input.AvailabilitySearchInputCompactSearchView_OneWay"}
Command duration or timeout: 15.96 seconds

1 个答案:

答案 0 :(得分:0)

有帧,所以你需要使用下面的代码切换帧:

driver.switchTo().frame(0) 

在鳕鱼行之前添加上面的代码以选择单选按钮