Selenium webdriver 嵌入span/li&;中时如何定位web元素;班

Selenium webdriver 嵌入span/li&;中时如何定位web元素;班,selenium-webdriver,Selenium Webdriver,下面是我的代码: <div class="rightMenu"> <ul> <!-- ngRepeat: item in tab.rightMenuList --> <li class="dropdown ng-scope" on-toggle="toggled(open)" dropdown="" ng-repeat="item in tab.rightMenuList"> <a class="dropdown-toggle" dropdo

下面是我的代码:

<div class="rightMenu">
<ul>
<!-- ngRepeat: item in tab.rightMenuList -->
<li class="dropdown ng-scope" on-toggle="toggled(open)" dropdown="" ng-repeat="item in tab.rightMenuList">
<a class="dropdown-toggle" dropdown-toggle="" ng-click="item.click()" href="" aria-haspopup="true" aria-expanded="false">
<!-- ngInclude: item.iconUrl -->
<span class="iconText ng-binding bvTextColor" font-color="">Cancel</span>
</a>
<ul class="dropdown-menu ng-hide" ng-show="(item.dropDownMenu.length > 0)">
<!-- ngRepeat: sort in item.dropDownMenu -->
</ul>
<ul class="dropdown-menu ng-hide" ng-show="(item.replyOptions.length > 0)">
<!-- ngRepeat: option in item.replyOptions -->
</ul>
</li>
<!-- end ngRepeat: item in tab.rightMenuList -->
<li class="dropdown ng-scope" on-toggle="toggled(open)" dropdown="" ng-repeat="item in tab.rightMenuList">
<a class="dropdown-toggle" dropdown-toggle="" ng-click="item.click()" href="" aria-haspopup="true" aria-expanded="false">
<!-- ngInclude: item.iconUrl -->
<span class="iconText ng-binding bvTextColor" font-color="">Save</span>
</a>

    toggle=“toggled(open)”dropdown=“”ng repeat=“tab.rightMenuList中的项”>
    toggle=“toggled(open)”dropdown=“”ng repeat=“tab.rightMenuList中的项”>
现在,我想使用SeleniumWeb驱动程序定位嵌入在锚定标记中的“Save”。请帮帮我
在此处输入代码

browser = webdriver.Firefox()
element = browser.find_element_by_css_selector("div.rightMenu > ul > li:nth-child(2) > a > span")
print element.text
在运行之前,尝试使用chrome控制台窗口进行测试。使用jquery:

$("div.rightMenu > ul > li:nth-child(2) > a > span).text()

另外,我不确定第n个孩子(2),我假设它从1开始,而不是从0开始。如果其最后一个
li

已从代码中重新格式化问题文本,您也可以尝试使用
“li:last child”