I need to click a button for a drop-down menu.
This is drop-down button for toggle. If I click on the button, it will drop-down and show an option. If the button is clicked again, the display will change back to original.
...
<div f-menu-item-submenu="$parent.createMenu" ng-if="!$root.ADMIN_RO && menu.menuBar" class="ng-scope ng-isolate-scope menu-item menu-item-submenu">
<button type="button" ng-class="{'selected': selected}" ng-disabled="disabled()" ng-click="onClick($event)">
<div class="flex-button-content" ng-transclude="">
<f-icon class="ftnt-add ng-scope"></f-icon><span class="ng-binding ng-scope">
Create New
</span><span class="flex-filler"></span><f-icon class="fa-caret-down toggle-indicator">
</f-icon>
</div>
</button>
</div>
First I try to find the element by using xpath:
elem = driver.find_element_by_xpath("/html/body/section/nav/ul/li[4]/div/ul/li[2]/div/ul/li[1]/a/span")
The Python says:
"Unable to locate element".
Then I try to find the element by using CSS slector:
elem = driver.find_element_by_css_selector(".left-menu-items > div.ng-scope.ng-isolate-scope.menu-item.menu-item-submenu > button > div > span.ng-binding.ng-scope")
The selenium still says:
"Unable to locate element"