How do I write an xpath so that I can click on the settings button with selenium in python for the following html. Clicking the element is made harder by the fact that the settings element doesn't have an own id.
<ul class="nav nav-tabs">
<li class="active">
<a data-toggle="tab" href="#editor">Structure</a>
</li>
<li>
<a data-toggle="tab" href="#feedback">Feedback</a>
</li>
<li>
<a data-toggle="tab" href="#settings">General settings</a>
</li>
I have tried multiple commands, but I don't seem to get it right.
I am using elements (plural) so that I can see if it matches any xpaths. Figured it would be the cleanest way to test out different xpaths. If I get the xpath correctly I will use element (singular) and add .click() to the end. I have tried at least these following codes.
driver.find_elements_by_xpath("//*[@class='nav nav-tabs']//*[href='#settings']")
--> return [] (xpath doesn't match?)driver.find_elements_by_xpath("//ul[contains(@class, 'nav-tabs')]")
--> returns []driver.find_elements_by_xpath(".//a[@href='#settings']")
--> return []
When I 'click' the element, it usually gives the following error message:
NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":".//a[@href='#settings']"}