Reputation: 7
I have many rows in a grid, listing just two below. When I select a row and click on a drop down, then only it displays the drop down menu. I want to select the Account Open drop down item only where it is displayed. What is the Xpath that I can use to achieve this? I noticed that where it is displayed, the style says
style="top: 446px; display: block; left: 76px; right: auto;">;
where as the others says display: none.
I came up with the below, but want to have only one Xpath with all in.
driver.find_element_by_xpath("//div[not(contains(@style,'display:none'))]//name['colActionDropdownMenu']")
driver.find_elements_by_xpath('//*[contains(@id, 'AccountOpen')]')
HTML :
<ul name="colActionDropdownMenu" class="dropdown-menu action-dropdown-menu noselect" dropdown-menu="" role="menu" style="top: 446px; display: none; left: 76px; right: auto;">
<li role="menuitem" ng-repeat="action in grid.appScope.validActions">
<a href="" id="AccountOpen" ng-click="grid.appScope.doAction(action)">Account Open</a>
</li><li role="menuitem" ng-repeat="action in grid.appScope.validActions">
</ul>
<ul name="colActionDropdownMenu" class="dropdown-menu action-dropdown-menu noselect" dropdown-menu="" role="menu" style="top: 269px; display: block; left: 76px; right: auto;">
<li role="menuitem" ng-repeat="action in grid.appScope.validActions">
<a href="" id="AccountOpen" ng-click="grid.appScope.doAction(action)">Account Open</a>
</li><li role="menuitem" ng-repeat="action in grid.appScope.validActions">
</ul>
Upvotes: 0
Views: 602
Reputation: 9058
Use the following xpath
"//ul[@name='colActionDropdownMenu'][contains(@style,'display: block')]//a[@id='AccountOpen']"
You can remove the id part for the link if you want.
Upvotes: 1