2017-04-08 19 views
0

如何在下拉菜單中循環顯示每個選項,而每個選項在計算機上打開新鏈接並在完成當前選項的處理後,我需要轉到下拉式的下一個選項。現在,要回到下一個選項,我要回到窗口,那裏有一個下拉框,我點擊下一個選項。那麼,是否有可能在我完成當前工作之後立即進入下一個選項?如何通過下拉選項進行循環,每個選項打開新鏈接時

選擇選項時,鏈接文檔在父框架中打開,這意味着鏈接在同一頁面中打開。它_parent標籤,它的作用同樣喜歡<a href="https://www.w3schools.com" target="_parent">

<select id="ab" name = "ab" 
      onchange = "javascript: var sel = getElementById('ab').selectedIndex; 
      var val = getElementById('ab').options[sel].value; 
      parent.location='http://ab/football/player_detail.php'+val;"> 

    <option value='?rez=77777playerNid=1&controls=2:4:5'>Nike.com</option> 
    <option value='?rez=464677playerNid=4&controls=2:4:5'>diablo.com</option> 

+0

什麼呢「,而每個選項打開計算機上的新鏈接「是什麼意思? – kushal

+0

是否打開一個新窗口? – kushal

+0

好的,這可以處理 – kushal

回答

0

你可以試試下面的代碼:

更新:

  Select select=new Select(driver.findElement(By.id("ab"))); 
      for(int i =0; i<select.getOptions().size();i++){ 
       select = new Select(driver.findElement(By.id("ab"))); 

       //selecting options 
       select.selectByIndex(i); 



       /*you can do nour work here depending upon option selected 
       * . 
       * . 
       * . 
       */ 


       driver.navigate().back(); 
      } 
+0

我試着用你的代碼,但它給了錯誤:** java.lang.NullPointerException:條目中的空值:name = null **。在你的代碼中,我插入了以下部分:'driver.switchTo()。window(newWindowHandle); driver.manage()。timeouts()。implicitlyWait(10,TimeUnit.SECONDS); driver.switchTo()。frame(「footballer_detail_frame」); findFootballer();' – Sean

+0

在哪一行它會拋出這個錯誤? – kushal

+0

你能分享你的網址嗎? – kushal

相關問題