2014-11-05 34 views
0

可以告訴我如何獲取下拉列表中的所有選項,並使用selenium web驅動程序將其與單個選項進行比較。獲取下拉列表中的所有選項,並使用單個選項使用硒webdriver和java

我嘗試了這種代碼

Select dropdown = new Select(_driver.findElement(EventListOptionList)); 
     List<WebElement> Options = dropdown.getOptions(); 
     for (WebElement el : Options) { 
      if(el.getText.equals("event1")){ 
      System.out.printLn("Option is present") 
      } 
     } 

但它顯示的錯誤在這行

List<WebElement> Options = dropdown.getOptions(); 

和錯誤是「刪除類型參數」

+0

你能提供HTML代碼片段嗎? – HemaSundar 2014-11-05 14:10:03

+0

這是特定行或運行時錯誤的編譯時錯誤嗎? – shri046 2014-11-05 16:12:02

回答

0

您必須導入此List類:「java.awt.List」。因此錯誤。
請刪除它並導入「java.util.List」。這一定會解決你的問題。

+0

問題解決tqq – Pushpa 2014-12-02 05:13:43

+0

真棒.. :)如果這有助於你,請將其標記爲答案。謝謝。 :) – Subh 2014-12-02 05:37:32

相關問題