我在下面的网页中找不到链接的XPath/CSS选择器:“Select Participant”,然后我将循环遍历所有链接。
<div class="glossymenu">
<a class="menuitem submenuheader" href="#" headerindex="0h"><span class="accordprefix"></span>Participant Management<span class="accordsuffix"><img src="../images/plus-ac.png" class="statusicon"></span></a>
<div class="submenu" contentindex="0c" style="display: none;">
<ul>
<li><a id="ParticipantManagement" style="cursor:pointer" onclick="javascript:CheckPermission('ParticipantManagement','ParticipantManagement.aspx')">Select Participant</a></li>
<li><a id="DocumentApproval" style="cursor:pointer" onclick="javascript:CheckPermission('DocumentApproval','DocumentApproval.aspx')">Quick Document Approval</a></li>
</ul>
</div>
<a class="menuitem submenuheader" href="#" headerindex="1h"><span class="accordprefix"></span>System Management<span class="accordsuffix"><img src="../images/plus-ac.png" class="statusicon"></span></a>
<div class="submenu" contentindex="1c" style="display: none;">
<ul>
<li><a id="ctl00_CommonMaster" style="cursor:pointer" onclick="javascript:CheckPermission('CommonMaster','CommonMaster.aspx')">Common Master Tables</a></li>
<li><a id="SystemEventMaintenance" style="cursor:pointer" onclick="javascript:CheckPermission('SystemEventMaintenance','SystemEventMaintenance.aspx')">Event</a></li>
<li><a id="ImportCategoryMaster" style="cursor:pointer" onclick="javascript:CheckPermission('ImportCategoryMaster','ImportCategoryMaster.aspx')">Import Configuration
Type </a></li>
<li><a id="ColumnRuleMapper" style="cursor:pointer" onclick="javascript:CheckPermission('ColumnRuleMapper','ColumnRuleMapper.aspx')">Import Column Rule Mapper</a></li>
<li><a id="ctl00_SMTPDetailMaster" style="cursor:pointer" onclick="javascript:CheckPermission('SMTPDetailMaster','SMTPDetailMaster.aspx')">SMTP Detail</a></li>
<li><a id="ClientCodeMaster" style="cursor:pointer" onclick="javascript:CheckPermission('ClientCodeMaster','ClientCodeMaster.aspx')">Client Code Master</a></li>
<li><a id="ClientMaster" style="cursor:pointer" onclick="javascript:CheckPermission('ClientMaster','ClientMaster.aspx')">Client Management</a></li>
<li><a href="UserEntryMaster.aspx" id="ctl00_UserEntryMaster">User And Role
Management</a></li>
<li><a id="Scheduler" style="cursor:pointer" onclick="javascript:CheckPermission('Scheduler','Scheduler.aspx')">Schedule</a></li>
<li><a id="TransactionStatements" href="TransactionStatement.aspx">Transaction Statements</a></li>
<li><a id="AddCustomColumn" style="cursor:pointer" onclick="javascript:CheckPermission('AddCustomColumn','AddCustomColumn.aspx')">Manage Custom Field</a></li>
</ul>
</div>
<a class="menuitem submenuheader" href="#" headerindex="2h"><span class="accordprefix"></span>Client/Case Configuration<span class="accordsuffix"><img src="../images/plus-ac.png" class="statusicon"></span></a>
<div class="submenu" contentindex="2c" style="display: none;">
<ul>
<li><a id="ClientCaseMaster" style="cursor:pointer" onclick="javascript:CheckPermission('ClientCaseMaster','ClientCaseMaster.aspx')">Case Management</a></li>
<li><a id="RegionMapping" style="cursor:pointer" onclick="javascript:CheckPermission('RegionMapping','RegionMapping.aspx')">Region Mapping</a></li>
<li><a id="ClassificationMaintenance" style="cursor:pointer" onclick="javascript:CheckPermission('ClassificationMaintenance','ClassificationMaintenance.aspx')">Classification
Maintenance</a></li>
<li><a id="SubClassificationMaintenance" style="cursor:pointer" onclick="javascript:CheckPermission('SubClassificationMaintenance','SubClassificationMaintenance.aspx')">Sub
Classification Maintenance</a></li>
<li><a id="PlanYearMaintenance" style="cursor:pointer" onclick="javascript:CheckPermission('PlanYearMaintenance','PlanYearMaintenance.aspx')">Plan Year Maintenance</a></li>
<li><a id="CarrierCompare" href="CarrierCompare.aspx">Carrier Compare</a></li>
<li><a id="Theme" style="cursor:pointer" onclick="javascript:CheckPermission('Theme','Theme.aspx')">Configure Client Style</a></li>
<li><a id="EmployeeDeshboardTiles" style="cursor:pointer" onclick="javascript:CheckPermission('EmployeeDashboardTile','EmployeeDashboardTile.aspx')">Employee Dashboard
Tile Management</a></li>
<li><a id="RelationShipManagement" style="cursor:pointer" onclick="javascript:CheckPermission('RelationShipManagement','RelationShipManagement.aspx')">Dependent Relationship Management</a></li>
</ul>
</div>
<a class="menuitem submenuheader" href="#" headerindex="3h"><span class="accordprefix"></span>Client Maintenance<span class="accordsuffix"><img src="../images/plus-ac.png" class="statusicon"></span></a>
<div class="submenu" contentindex="3c" style="display: none;">
<ul>
<li><a id="TierCustomCodeMaster" style="cursor:pointer" onclick="javascript:CheckPermission('TierCustomCodeMaster','TierCustomCodeMaster.aspx')">Tier CustomCode Master</a></li>
<li><a id="BenefitSetup" style="cursor:pointer" onclick="javascript:CheckPermission('BenefitSetup','BenefitSetup.aspx')">Benefits</a></li>
<li><a id="PlanSetup" style="cursor:pointer" onclick="javascript:CheckPermission('PlanSetup','PlanSetup.aspx')">Plans</a></li>
<li><a id="Events" style="cursor:pointer" onclick="javascript:CheckPermission('ClientEvent','ClientEventMaintenance.aspx')">Events</a></li>
<li><a id="EventWebDirections" style="cursor:pointer" onclick="javascript:CheckPermission('EventWebDirection','EventWebDirection.aspx')">Manage Event Web Directions</a></li>
<li id="ctl00_liTriggerEvent" style="display:none;"><a id="TriggerEvent" href="TriggerEvent.aspx>
Trigger An Event</a></li>
<li><a id=" deletedependency"="" style="cursor:pointer" onclick="javascript:CheckPermission('DeleteDependency','DeleteDependency.aspx')">Delete Dependency</a></li>
<li><a id="AdminStatements" style="cursor:pointer" onclick="javascript:CheckPermission('AdminStatements','AdminStatements.aspx')">Admin Statements</a></li>
<li><a id="FormLibrary" style="cursor:pointer" onclick="javascript:CheckPermission('FormsLibrary','FormsLibrary.aspx')">Forms Library</a></li>
<li><a id="UpdateEventDate" style="cursor:pointer; display:none" onclick="javascript:CheckPermission('UpdateEventDate','UpdateEventDate.aspx')">Update Event Date</a></li>
</ul>
</div>
<a class="menuitem submenuheader" href="#" headerindex="4h"><span class="accordprefix"></span>Client Import Administration<span class="accordsuffix"><img src="../images/plus-ac.png" class="statusicon"></span></a>
<div class="submenu" contentindex="4c" style="display: none;">
<ul>
<li><a id="TriadMapping" style="cursor:pointer" onclick="javascript:CheckPermission('TriadMapping','TriadMapping.aspx')">Client Code Mapper</a></li>
<li><a id="ImportTemplate" style="cursor:pointer" onclick="javascript:CheckPermission('ImportTemplate','ImportTemplate.aspx')">Import Template</a></li>
<li><a id="ImportReport" href="ImportReport.aspx">Import History</a></li>
<li><a id="VerifyEmployeeDetails" href="VerifyEmployeeDetails.aspx">Review/Approve Client
Import Files</a></li>
</ul>
</div>
<a class="menuitem submenuheader" href="#" headerindex="5h"><span class="accordprefix"></span>Email Administration<span class="accordsuffix"><img src="../images/plus-ac.png" class="statusicon"></span></a>
<div class="submenu" contentindex="5c" style="display: none;">
<ul>
<li><a id="EmailTemplate" style="cursor:pointer" onclick="javascript:CheckPermission('EmailTemplate','EmailTemplate.aspx')">Email Template</a></li>
<li><a id="EmailConfiguration" style="cursor:pointer" onclick="javascript:CheckPermission('EmailConfiguration','EmailConfiguration.aspx')">Email Configuration</a></li>
<li><a id="EmailQueue" style="cursor:pointer" onclick="javascript:CheckPermission('EmailQueue','EmailQueue.aspx')">Email Queue</a></li>
</ul>
</div>
<a class="menuitem submenuheader" href="#" headerindex="6h"><span class="accordprefix"></span>Content Management System<span class="accordsuffix"><img src="../images/plus-ac.png" class="statusicon"></span></a>
<div class="submenu" contentindex="6c" style="display: none;">
<ul>
<li><a id="CMSLeftMenu" style="cursor:pointer" onclick="javascript:CheckPermission('CMSLeftMenu','CMSLeftMenu.aspx')">Left Menu Configuration</a></li>
<li><a id="CMSImage" style="cursor:pointer" onclick="javascript:CheckPermission('CMSTile','CMSImage.aspx')">Tile Configuration</a></li>
<li><a id="CMSContent" style="cursor:pointer" onclick="javascript:CheckPermission('CMSContent','CMSContent.aspx')">Content Configuration</a></li>
<li><a id="CMSRightPanel" style="cursor:pointer" onclick="javascript:CheckPermission('CMSRightPanel','CMSRightPanel.aspx')">Page Configuration</a></li>
<li><a id="CMSAlertsMaster" style="cursor:pointer" onclick="javascript:CheckPermission('CMSAlert','CMSAlertsMaster.aspx')">CMS Alert Template</a></li>
<li><a id="PrivacyStatementMaster" style="cursor:pointer" onclick="javascript:CheckPermission('PrivacyStatementMaster','PrivacyStatementMaster.aspx')">Privacy Statement</a></li>
<li><a id="AppearanceOrder" style="cursor:pointer" onclick="javascript:CheckPermission('AppearanceOrder','AppearanceOrder.aspx')">Appearance Order</a></li>
</ul>
</div>
<a class="menuitem submenuheader" href="#" headerindex="7h"><span class="accordprefix"></span>Document Management System<span class="accordsuffix"><img src="../images/plus-ac.png" class="statusicon"></span></a>
<div class="submenu" contentindex="7c" style="display: none;">
<ul>
<li><a id="DMSCategory" style="cursor:pointer" onclick="javascript:CheckPermission('DMSCategory','DMSCategory.aspx')">Document Category</a></li>
<li><a id="DMSAddDocument" style="cursor:pointer" onclick="javascript:CheckPermission('DMSAddDocument','DMSAddDocument.aspx')">Document Library</a></li>
</ul>
</div>
<a class="menuitem submenuheader" href="#" headerindex="8h"><span class="accordprefix"></span>OE Management System<span class="accordsuffix"><img src="../images/plus-ac.png" class="statusicon"></span></a>
<div class="submenu" contentindex="8c" style="display: none;">
<ul>
<li><a id="OEManagementSystem" style="cursor:pointer" onclick="javascript:CheckPermission('OEEventCreation','OEEventCreation.aspx')">Make OE Events</a></li>
<li><a id="ImportExportPayCalendar" style="cursor:pointer" onclick="javascript:CheckPermission('ImportExportPayCalendar','ImportExportPayCalendar.aspx')">Import/Export
Pay Calendar</a></li>
</ul>
</div>
<a class="menuitem submenuheader" href="#" headerindex="9h"><span class="accordprefix"></span>Logs<span class="accordsuffix"><img src="../images/plus-ac.png" class="statusicon"></span></a>
<div class="submenu" contentindex="9c" style="display: none;">
<ul>
<li><a id="LoginTrack" href="LoginTrack.aspx?IsFromlink=Yes">Login History</a></li>
<li><a id="ErrorLog" href="ErrorLog.aspx">Error Log</a></li>
<li><a id="ErrorLogWatcher" href="ErrorLogWatcher.aspx">Application Exceptions</a></li>
</ul>
</div>
<a class="menuitem submenuheader" href="#" headerindex="10h"><span class="accordprefix"></span>Outbound Files<span class="accordsuffix"><img src="../images/plus-ac.png" class="statusicon"></span></a>
<div class="submenu" contentindex="10c" style="display: none;">
<ul>
<li><a id="ReviewOutboundFiles" href="ReviewOutboundFiles.aspx">Review Outbound Files</a></li>
</ul>
</div>
<a href="#" id="ctl00_Security" class="menuitem submenuheader" headerindex="11h"><span class="accordprefix"></span>Security<span class="accordsuffix"><img src="../images/plus-ac.png" class="statusicon"></span></a>
<div class="submenu" contentindex="11c" style="display: none;">
<ul>
<li><a id="ctl00_ClientCase" style="cursor:pointer" onclick="javascript:CheckPermission('ClientCase','ClientCase.aspx')">Client/Case Permission</a></li>
<li><a id="UserPageEntry" style="cursor:pointer" onclick="javascript:CheckPermission('UserPageEntry','UserPageEntry.aspx')">Page Master</a></li>
<li><a id="UserPermission" href="UserPagePermission.aspx">Page Rights</a></li>
<li><a id="ParticipantView" href="ParticipantView.aspx">Participant Page View</a></li>
</ul>
</div>
</div> //
列表链接=driver.findElements(By.xpath(“//div[contains(@class='glossymenu')]//a”);迭代器iter=links.Iterator();//system.out.println(“CLASS Elements size”+We.GetText());while(iter.hasNext()){
WebElement we = iter.next();
//System.out.println(" CLASS Elements size " + we.getText());
if (we.getText().contains("Select Participant")) {
we.click();
break;
}
}
//system.out.println(“CLASS Elements size”+We.GetText());
链接的XPath/CSS选择器:“Select Participant”://div[contains(@class='glossymenu')]//a[text()='select Participant']
我一直在为这个selenium项目苦苦挣扎,一直在寻找与这个问题略有关联的老参考资料或帖子。我承认我不熟悉xpath和selenium,所以希望它可以像修复语法一样简单。我正在使用python 3.6。卢本图19.10上的9,如果这有什么区别的话。 我试图访问的html元素: 我尝试过的代码: 尝试不同的XPath时出现的错误消息: 我检查了火狐来尝试捕获xpath,显示为: 虽然我还不确定如何调
我一直试图使用硒网络驱动程序找到以下按钮: 我使用了css选择器、xpath和类,但似乎什么都不起作用(即使只是复制粘贴了inspector给出的一个。最近的一次是使用类_1ibtygfe定位div)。这是我尝试过的一切,我很绝望,我不明白为什么它找不到它,它一直向我抛出一个无此类元素异常。 这是airbnb网站,我正在尝试抓取他们的活动并点击查看更多按钮。谢谢你的帮助。
我正在使用Selenium(Java版本)测试一个基于OpenLayers的API。 我想测试一个使用的功能。控制修改功能。我想单击绘制的特征(SVG),然后拖动并检查它们是否存在、可见或隐藏。 我已经画了一个多边形,并且选择了它。见下图: 这些SVG元素的HTML如下所示: 假设我想选择红点。 我试过: 但是它总是返回一个空列表。 我做错了什么?有人能帮我吗? 多谢了。 编辑1-功能:垂直显示可
问题内容: 我是xpath的新手,尝试使用xpath获取“值”的值: 虽然很容易找到像这样的元素: 我还无法弄清楚如何获得所需的值,例如: 某些预期会产生错误: 任何想法如何解决这个问题? 编辑:xpath是正确的,但是它“返回”了obj属性,并且由于它不是元素,因此不允许使用。我找不到类似get_attr_by_xpath()之类的方法。 问题答案: 我最终用作:
我是xpath的新手,试图使用xpath获取“value”的值: 虽然通过很容易找到元素,但如下所示: 我还没能弄清楚如何获得我需要的值,因为: 有点意外地给出了一个错误: 有什么办法解决这个问题吗? 编辑:xpath是正确的,但它“返回”一个obj属性,因为它不是元素,所以不允许使用。我找不到像get_attr_by_xpath()这样的方法,或者任何类似的方法。
问题内容: 在我的网页中,有一个名为的。 我如何找到它? 问题答案: 此选择器应该可以工作,但是如果您用合适的标记替换它,效率会更高: 或者,由于我们知道所搜索的元素是: 但是,因为这也可以匹配诸如或的情况,所以注释中提供的@Tomalak版本 更好 : 如果您真的想确定它可以正确匹配,则还可以使用normalize-space函数清除类名周围的杂散空格字符(如@Terry所述): 请注意,在所有