我有以下的HTML代碼,我需要選擇突出顯示的元素。如果菜單高亮顯示,我想選擇菜單中的按鈕而不是菜單!如果菜單是賽場,我想選擇它。選擇按鈕的XPath?
<menu id="apl" class="highlight" widgetid="apl">
<button id="navi" selectable="true" widgettype="button" widgetid="audio_radio_apl_navi">
<button id="audio" class="highlight" selectable="true" widgettype="button" widgetid="audio_radio_apl_audio">
<button id="tel" selectable="true" widgettype="button" widgetid="audio_radio_apl_tel">
<button id="video" selectable="true" widgettype="button" widgetid="audio_radio_apl_video">
<button id="system" selectable="true" widgettype="button" widgetid="audio_radio_apl_system">
<button id="net" selectable="true" widgettype="button" widgetid="audio_radio_apl_net">
</menu>
<menu id="plf" widgetid="plf">
<img src="img/plf_radio.png"/>
</menu>
到目前爲止我的代碼是:
focusedElement = driver.findElement(By.xpath("//*[contains(@class,'highlight')]"));
這讓我突出顯示的菜單,但我需要的按鈕! 任何想法?
你能定義一下'如果菜單是賽場,我想選擇那'意味着你? – predi
如果我選擇一個菜單,然後選擇菜單[@ class,'highlight']。但我不想選擇菜單元素。我想要突出顯示的按鈕,這是突出顯示的菜單的子項。如果菜單[@ id,'plf']那麼我想要菜單,因爲它沒有按鈕。 –