Select XPath of a Button?
34,051
try this one
focusedElement = driver.findElement(By.xpath("//button[@class='highlight']"));
as simple as it can get or
Select selectBox = new Select(driver.findElement(By.xpath("//menu[@id='apl']")));
Author by
Hans En
Updated on September 24, 2020Comments
-
Hans En over 3 years
I have the following HTML Code I need to select the Element that is highlighted. If the menu is highlighted I would like to select the button in the menu not the menu! If the menu is playfield I would like to select that.
<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>
My code so far is:
focusedElement = driver.findElement(By.xpath("//*[contains(@class,'highlight')]"));
This gets me the highlighted menu but I need the button! Any ideas?