Can anyone help me in writing xPath for below image, I wrote one but it's not working.
My xPath is //li[@class='active']//a[@class='dropdown-button btn']
If you don't mind switching to CSS selectors, use the following:
CSS selector: #nav-mobile .active a.dropdown-button.btn
Try using below XPath:
//a[@class='dropdown-button btn'];
Try below Xpath and share your feedback
//*[contains(@class,'active')]/descendant::a[@class='dropdown-button btn']
You can copy the xpath from the Chrome/Firefox inspect elements:
1- Put the mouse on the element you want to inspect
2- Right click, Inspect element
3- Down bar shows, Right clikc, copy, copy xpath
Done!
I think the li element gets active only when you hover or click it. Please try to hover/click on the parent element and then try searching for your XPath.