【发布时间】:2016-01-05 22:46:17
【问题描述】:
我昨天偶然发现了 Selenium,并且能够成功登录网站并导航到我通常必须手动完成的页面。我试图复制 xpath,但找不到该元素。它看起来像这样:
我对其进行了编辑以包含检查元素的顶部。这归结为“导出为 PDF”选项,请记住我想要的是 CSV 格式,而不是 PDF。
<document>
<html lang="en" dir="ltr" style="visibility: visible;">
<head>
<body class="PortalBody HTMLBody" style="">
<div class="HeaderContainer">
<script type="text/javascript">obips.history.create();</script>
<form style="position: absolute; top: -1000px; display:none;">
<script>var dashboardCurrentStyle = "FusionFx" </script>
<div id="idEmbedFrameDiv" style="" src="saw.dll?ReloadDashboard&InFrameset=false&Page=Dashboard%20Insight&Embed=true&PortalPath=%2fshared%20-%20DW%2f_portal%%20Dashboard%20Detail&Caller=Dashboard&ViewState=01qglnht7bjvn3nf9qrofvafjm"/>
<script type="text/javascript">obips.ResourceManager.seedResource({p:"common/privileges.xml",v:{exprs:{"canAccessCatalogUI":true,"canAccessCatalogSearchUI":false,"canAccessHomePage":true,"canAccessSimpleSearchField":false,"canAccessAdvancedSearchLink":false,"canAccessOpenMenu":true,"canAccessNewMenu":true,"canAccessHelpMenu":true,"canAccessDashboardsMenu":true,"canAccessFavoritesMenu":true,"canAccessMyAccountLink":true,"canAccessCustomLinks":false,"enableClientStorage":true,"enableSessionStorage":true,"enableLocalStorage":true,"canReloadMetadata":false,"canOpenMetadataDict":false}}});saw.header.alertsNode = ""; saw.header.renderHeader(null, 'Dashboard Detail', '', '', {'Oracle': 'olh/l_en/toc.htm', 'Oracle Publisher': "saw.dll?xmlpObjectTasks" + '&Action=help', 'Marketing': 'olh/l_en/marketing/mstoc.html' });saw.getSessionInfos().portalPath='/shared/_portal/Dashboard Detail';</script>
<script type="text/javascript">obidash.pageIdentifier = 'sfcjp24m8jpf8gbu';obidash.canSaveSelectionForMe = true;</script>
<div id="idPersonalizationMenu" class="NQWMenu" sdir="right" menuinit="" href="javascript:void(null)" onmouseout="NQWMenuMouseOut(event)" onmouseover="NQWMenuMouseOver(event)">
<div id="idDashboardPrintDisplayLayoutMenu" class="NQWMenu" sdir="left" submenuinit="" href="javascript:void(null)" onmouseout="NQWMenuMouseOut(event)" onmouseover="NQWMenuMouseOver(event)">
<div id="idDashboardPrintManageLayoutMenu" class="NQWMenu" sdir="left" submenuinit="" href="javascript:void(null)" onmouseout="NQWMenuMouseOut(event)" onmouseover="NQWMenuMouseOver(event)">
<div id="idDashboardExportToExcelMenu" class="NQWMenu" sdir="left" submenuinit="" href="javascript:void(null)" onmouseout="NQWMenuMouseOut(event)" onmouseover="NQWMenuMouseOver(event)">
<div id="idSavedSelectionsMenu" class="NQWMenu" sdir="left" submenuinit="PersonalizationEditor.getSavedSelectionsMenu" href="javascript:void(null)" onmouseout="NQWMenuMouseOut(event)" onmouseover="NQWMenuMouseOver(event)">
<script src="res/b_mozilla/common/componentheader.js" type="text/javascript"/>
<span id="sawruler" style="display:none;visibility:hidden;white-space:nowrap;"/>
<div class="ComponentHeader ">
<iframe id="idEmbed" style="visibility: hidden; width: 0px; height: 0px; position: absolute; top: 0px;" src="res/empty.htm" name="idEmbed" title="idEmbed"/>
<div id="idDownloadLinksMenud:dashboard~p:sfcjp24m8jpf8gbu~r:tom49amoppk60jjc" class="NQWMenu" onmouseover="NQWMenuMouseOver(event)" style="visibility: visible; display: block; position: absolute; top: 422px; left: 820px;" binit="true" role="menu" aria-activedescendant="popupMenuItem">
<table class="menuShadowWrapper" cellspacing="0">
<tbody>
<tr>
<td class="shadowMenuCell" colspan="2" rowspan="2">
<a id="popupMenuItem" class="NQWMenuItem NQWMenuItemWIconMixin" onclick="NQWClearActiveMenu();Download('saw.dll?Go&ViewID=d%3adashboard%7ep%3asfcjp24m8jpf8gbu%7er%3atom49amoppk60jjc&Action=Download&SearchID=c7gl7pgfjfdkhekcg09p3p8guq&Style=FusionFx&PortalPath=%2fshared%20-%20DW%2f_portal%20Dashboard%20Detail&Page=Dashboard%20Insight&ViewState=5cb5o5dpdpsh5id2japa3i0rvu&ItemName=Report%20Data&path=%2fshared%20-%20DW%20Dashboard%20New%20Report%20Data&Format=pdf&Attach=1'); return false" href="javascript:void(null);" name="SectionElements" style="width: 119px;" tabindex="0" role="menuitem" aria-label="PDF">
<table class="MenuItemTable" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="MenuItemIconCell">
<td class="MenuItemTextCell">PDF</td>
</tr>
</tbody>
</table>
</a>
【问题讨论】:
-
好吧,如果你能显示完整的 HTML 代码或 URL 那就更好了。但是如果你真的做不到,你的 HTML 代码部分只有一个
a标签,你想直接点击吗? -
看起来您需要使用
ActionChain()类及其相关方法。它将允许您执行您可能需要执行的鼠标悬停类型的操作。 -
我尝试添加更多信息,希望对您有所帮助。不幸的是,我对这些东西完全陌生。