Hi,
I want to click on an element path under svg. I am using the xpath //*[@id="buttonname"]/span[1]/svg/path to click on the element.
However it is not able to interact with it.
Following is the html. How can I interact with the element?
<body>
<div id="root">
<div>
<div>
<header class="headerclass">
<div class="firstdivclass">
<button class="buttonclass" tabindex="0" type="button" id="buttonname" aria-label="menu">
<span class="firstspanclass">
<svg class="svgclass" focusable="false" viewBox="0 0 24 24" aria-hidden="true">
<path d="path"></path>
</svg>
</span>
<span class="secondspanclass"></span>
</button>
<h5 class="h5class">Name</h5>
</div>
</header>
</div>
<div class="seconddivclass"></div>
<div class="thirddivclass">
<div class="fourthdivclass">
<h6 class="h6class">Welcome</h6>
</div>
</div>
</div>
</div>
<script src="jspath"></script>
</body>
Instructor
09914040666 Replied on 12/04/2021
Hey,
What is the exception coming?
It was that the element //*[@id="buttonname"]/span[1]/svg/path is not found
I found the solution. I had to modify the xpath to:
//*[@id="buttonname"]/span[1]/*[name()="svg"][@class="svgclass"]
Instructor
09914040666 Replied on 14/07/2021
Hey,
Thank you for the update. For future if anything like this happens, you may use the tools available for xpath creation.