2017-03-03 3 views
0

ドロップダウンメインにはDIVタグとIMGタグの両方のIDがありますが、いずれかを使用してドロップダウンメインをクリックすることはできますが、ドロップダウンオプションをクリックすることはできません。ドロップダウンメインのselenium webdrive javaを使用してスパンタグに存在するドロップダウンオプションを選択するにはどうすればよいですか?

ソースコード:ドロップダウンオプションの1の

<div id="drop_mainmenu" tabindex="0">Navigator 

<img id="mainmenu_downarrow" border="0" class="ArrowImg" alt="" title="" src="/jde/share/images/menu_l23_button_dropdown_dwn.png" onmouseover="this.src='/jde/share/images/menu_l23_button_dropdown_ovr.png'" onmousedown="this.src='/jde/share/images/menu_l23_button_dropdown_dwn.png'" onmouseout="this.src='/jde/share/images/menu_l23_button_dropdown_dwn.png'" data-pin-nopin="true"><br> 
</div> 

ソースコード:

<span id="fldnode140398" style="color: #000000;font-style: normal;" title="Task Type:Task View, Fastpath Code: TV:140">Christie's Dubai</span> 
+0

あなたはそれをclick'する 'ことができないのはなぜ?コードを共有する – Andersson

+0

ここに私のコード、driver.findElement(By.id( "mainmenu_downarrow"))。click(); Select mainmenu_downarrow = new Select(driver.findElement(By.id( "mainmenu_downarrow")))); \t \t \t \t mainmenu_downarrow.selectByVisibleText( "Christie's Dubai"); – Jagadeesh

+0

選択は動作しません。選択されたHTMLコードが選択されているようです。 –

答えて

0

一部waitを入れて試してみてみます

driver.findElement(By.id("mainmenu_downarrow")).click(); 
Thread.sleep(3000L); 
driver.findElement(By.xpath(".//span[contains(text(), 'Christie's Dubai')]")).click(); 

OR

driver.findElement(By.id("mainmenu_downarrow")).click(); 
Thread.sleep(3000L); 
driver.findElement(By.xpath(".//span[contains(@id, 'fldnode140398')]")).click(); 

OR

driver.findElement(By.id("mainmenu_downarrow")).click(); 
Thread.sleep(3000L); 
driver.findElement(By.xpath(".//span[starts-with(@id, 'fldnode')]")).click(); 
+0

あなたのxpathはここでは動作しません。セレンは '' s'を認識しません –

+0

これは私のコードで試したものですが、動作しません。 driver.findElement(By.id( "mainmenu_downarrow"))。クリック(); \t \t \t \t Thread.sleep(3000L); \t \t \t \t driver.findElement(.xml) "をクリックしてください。 – Jagadeesh

+0

私はそれを編集しました。 –

関連する問題