2016-04-21 314 views
0

我想點擊香料噴氣預訂航班頁。我寫在網絡驅動器格式,但按鈕無法下面的代碼的單向單選按鈕,單擊無法點擊的單選按鈕

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 

回答

0

有框架,所以你需要使用下面的代碼來切換框架:

driver.switchTo().frame(0) 

添加上面的代碼鱈魚行前選擇單選按鈕

+0

你怎麼......可以請註明 – swagatika