我有以下的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']那么我想要菜单,因为它没有按钮。 –