我正在尝试使用 selenium 和 python 单击按钮,但我无法单击它。
<div id="environmentNavigation" class="yui-navset yui-navset-top">
<ul class="yui-nav">
<li nav="myDash" class="" title="">
<a href="#" hidefocus="true">
<em>My dashboard</em>
</a>
</li>
<li nav="myApp">
<a href="#" hidefocus="true">
<em>My applications</em>
</a>
</li>
<li nav="myPermits" class="" title="">
<a href="#" hidefocus="true">
<em>My permits</em>
</a>
</li>
<li nav="allPermits" class="" title="">
<a href="#" hidefocus="true">
<em>All permits</em>
</a>
</li>
<li nav="myDetails" class="selected" title="active">
<a href="#" hidefocus="true">
<em>My Details</em>
</a>
</li>
</ul>
</div>
这是 HTML 源代码,我想单击所有许可按钮,我尝试使用 XPath,link_text 但没有任何效果。请在这里帮助我。该网站是机密的,需要登录,所以我无法分享,非常感谢您的帮助。
Webdriver 对象:
driver=webdriver.Chrome(executable_path=chromedriver_path)
driver.get('https://myminesonline.business.qld.gov.au/suite/apps')
wait=WebDriverWait(driver,10)
完整的 XPATH:
wait.until(EC.element_to_be_clickable((By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[4]'))).click()
XPATH:
wait.until(EC.element_to_be_clickable((By.XPATH,'//*[@id="environmentNavigation"]/ul/li[4]'))).click()
driver.page_source
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<title>My dashboard | Appian Application Portal</title>
<meta http-equiv="content-type" content="text/html">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
<link rel="shortcut icon" href="/suite/portal/img/appian_16x16.ico?appian_environment=">
<link rel="icon" href="/suite/portal/img/appian_48x48.png?appian_environment=" sizes="48x48">
<link rel="icon" href="/suite/portal/img/appian_32x32.png?appian_environment=" sizes="32x32">
<script type="text/javascript">
(function() {
var hash = window.sessionStorage && sessionStorage.getItem(\'hash\');
if (hash) {
sessionStorage.removeItem(\'hash\');
window.location = window.location + hash;
}
// do not use h:rewrite or c:url because the path already indicates
// the environment, and we don\'t want the environment to show up in the address bar
var envPath = \'/suite/apps\';
// validate browser URL is that of the current environment
var envPathRegEx = /\\/suite\\/apps/i;
var isAddressBarOk = !!top.location.href.match(envPathRegEx);
if (!isAddressBarOk) {
top.location.href = envPath;
return;
}
// validate that we don\'t try to load index inside index (infinite loop)
if (top != self) {
var isTopIndex = !!top.fContent; // assume if there\'s fContent in top, then top is index.jsp
if (isTopIndex) {
// index.jsp ended up nested in itself; default to environment entry point
top.fContent.location.href = \'/suite/portal/loadEnvironmentHome.do?appian_environment=apps\';
} else {
top.location.href = envPath;
}
return;
}
})();
window.APPIAN = {
};
</script>
</head>
<frameset rows="*, 0" border="0">
<frame name="fContent" id="fContent" src="/suite/portal/loadEnvironmentHome.do?appian_environment=apps" noresize="" title="Main Content Frame">
</frameset>
<noframes>
This site requires frames. Please turn on frame support in your web browser.
</noframes>
</html>
好像我需要的标签不在这些里面。我现在该怎么办?
从检查元素复制的正文标签
<body class="yui-skin-sam" onload="if (typeof timeout == 'function') { timeout(); }" onbeforeunload="window.eventCache.flushAll();" data-new-gr-c-s-check-loaded="14.1002.0" data-gr-ext-installed=""><iframe id="_yuiResizeMonitor" style="position: absolute; visibility: visible; width: 10em; height: 10em; top: -124px; left: -124px; border-width: 0px;"></iframe>
<a id="skipNavigationLink508" href="#environmentContent">Jump to content</a>
<script type="text/javascript">
window.decorator = 'main';
if (isIE) { $("body").addClass("isIE"); }
</script>
<div id="bodyDecoratorContainer">
<iframe name="fProcess" id="fProcess" style="display:none;position:absolute;width:600px;height:400px;margin:100px;top:0;left:0px;z-index:100;" src="/suite/portal/blank.jsp" title="Background processing frame. No displayed content."></iframe>
<iframe name="popupTarget" id="popupTarget" style="display:none;" src="/suite/portal/blank.jsp" title="Background processing frame. No displayed content."></iframe>
<div id="mainContent" style="">
<div id="environmentHeader">
<div class="a1">
<div class="b1">
<img src="/suite/portal/img/skins/default/app.gif" id="applicationIcon" alt="Application"></div>
<div class="b2 appName" id="applicationName" title="MyMinesOnline - Click here to view available applications"><a href="#" id="applicationNameLink">MyMinesOnline</a></div>
<div class="b3">
<div id="topNavItemsMenu" class="yuimenu yui-module yui-overlay" style="position: absolute; visibility: hidden;">
<div class="bd">
<ul class="first-of-type">
<li topnavid="myminesonline" id="yui-gen0" class="yuimenuitem first-of-type" groupindex="0" index="0">
<a href="#" title="" class="yuimenuitemlabel">
MyMinesOnline
</a>
</li>
</ul>
<div class="dividerContainer"><div class="menuDivider"></div></div>
<ul class="first-of-type">
<!-- Remove comments to re-enable dropdown items.
<li topNavId="system.tasks" >
<a href="#">
Tasks
</a>
</li>
<li topNavId="system.alerts" >
<a href="#">
Alerts
</a>
</li>
-->
</ul>
</div>
</div>
<script>
(function(){
YAHOO.widget.MenuManager.removeMenu(YAHOO.widget.MenuManager.getMenu('topNavItemsMenu'));
var menu = new YAHOO.widget.Menu('topNavItemsMenu', {
maxheight: 400,
scrollincrement: 2,
context: ["applicationNameLink",
YAHOO.widget.Overlay.TOP_RIGHT,
YAHOO.widget.Overlay.BOTTOM_RIGHT]
});
menu.hide();
var showFn = function () {
menu.render();
menu.align();
menu.show();
}
YAHOO.util.Event.addListener('applicationName', 'click', showFn, null, menu);
var menuElements = $("#topNavItemsMenu li");
for (var i = 0; i < menuElements.length; i++) {
var menuItem = menuElements.get(i);
YAHOO.util.Event.addListener(menuItem, 'click', function(){
var topNavId = this.getAttribute('topNavId');
ApplicationPortalUtils.loadTopNavigation(topNavId, ApplicationPortalUtils.defaultNavItem);
return false;
}, menuItem);
}
})();
</script></div>
</div>
<div class="a2">
<div class="c1">
<div class="d1">
<!-- Remove comment tags to re-enable links.
<a hidefocus="true" href="/suite/tempo" class="headerTempoIcon" title='Launch Tempo in new window' target="tempoWindow">Tempo</a>
<a hidefocus="true" href="#" class="sprite inbox" onclick="ApplicationPortalUtils.loadTopNavigation('system.tasks', ApplicationPortalUtils.defaultNavItem); return false;">Tasks<span class="taskCount"></span></a>
<a hidefocus="true" href="#" class="sprite alerts" onclick="ApplicationPortalUtils.loadTopNavigation('system.alerts', ApplicationPortalUtils.defaultNavItem); return false;">Alerts<span class="notificationCount"></span></a>
-->
<a hidefocus="true" href="#" class="sprite preferences" onclick="backgroundAction('/portal/updateUserPreferences.do','asiDialog');" title="Click to modify preferences">anitalee.ishere@yahoo.com</a>
<!--
<a hidefocus="true" href="https://docs.appian.com/suite/help/19.3" target="_blank" class="sprite help" title="Open User Guide in new window" hidefocus="hidefocus">Help</a>
-->
<a hidefocus="true" href="#" class="sprite logout" onclick="logout();">Sign Out</a>
</div>
</div>
<div class="c2">
<a id="logo" href="#" onclick="return false;"><img src="/suite/portal/img/skins/default/companylogo.png" height="31px" alt="MyMinesOnline"></a>
</div>
</div>
<div class="clearboth"></div>
</div>
<script>
(function(){
$("#logo").click(function(){
var homeApplicationId = '';
if (!StringUtils.isBlank(homeApplicationId)){
ApplicationPortalUtils.loadTopNavigation(homeApplicationId, ApplicationPortalUtils.defaultNavItem);
}
return false;
});
})();
</script>
<div id="environmentNavigation" class="yui-navset yui-navset-top">
<ul class="yui-nav">
<li nav="myDash" class="" title=""><a href="#" hidefocus="true"><em>My dashboard</em></a></li><li nav="myApp"><a href="#" hidefocus="true"><em>My applications</em></a></li><li nav="myPermits"><a href="#" hidefocus="true"><em>My permits</em></a></li><li nav="allPermits" class="" title=""><a href="#" hidefocus="true"><em>All permits</em></a></li><li nav="myDetails" class="selected" title="active"><a href="#" hidefocus="true"><em>My Details</em></a></li></ul>
<div class="yui-content"><div style="display: none;"></div><div style="display: none;"></div><div style="display: none;"></div><div style="display: none;"></div><div style="display: block;"></div></div></div>
<script>
(function(){
var tabView = new YAHOO.widget.TabView('environmentNavigation');
// We add an entry under the ApplicationPortalUtils.defaultNavItem key to represent the default secondary navigation
// item (tab) to be displayed for the current top-navigation item ("app"). It will always be the first item in the list.
var navItemDefaultContent = {};
navItemDefaultContent[ApplicationPortalUtils.defaultNavItem] = {};
navItemDefaultContent[ApplicationPortalUtils.defaultNavItem]['url'] = '\/portal.bg?appian_environment=apps&%24p=67';
navItemDefaultContent[ApplicationPortalUtils.defaultNavItem]['index'] = 0;
navItemDefaultContent['myDash'] = {};
navItemDefaultContent['myDash']['url'] = '\/portal.bg?appian_environment=apps&%24p=67';
navItemDefaultContent['myDash']['index'] = '0';
navItemDefaultContent['myApp'] = {};
navItemDefaultContent['myApp']['url'] = '\/portal.bg?appian_environment=apps&%24p=86';
navItemDefaultContent['myApp']['index'] = '1';
navItemDefaultContent['myPermits'] = {};
navItemDefaultContent['myPermits']['url'] = '\/portal.bg?appian_environment=apps&%24p=88';
navItemDefaultContent['myPermits']['index'] = '2';
navItemDefaultContent['allPermits'] = {};
navItemDefaultContent['allPermits']['url'] = '\/portal.bg?appian_environment=apps&%24p=85';
navItemDefaultContent['allPermits']['index'] = '3';
navItemDefaultContent['myDetails'] = {};
navItemDefaultContent['myDetails']['url'] = '\/portal.bg?appian_environment=apps&%24p=53';
navItemDefaultContent['myDetails']['index'] = '4';
Environment.Navigation.afterContentLoad = function(content) {
// #39204: Show main content after we finished loading everything to avoid flickering.
$("#mainContent").show();
};
/**
* Navigates into a new tab in the designer portal environment.
*
* @param {String} navToken The URL identifier corresponding to the secondary navigation item. Optionally it
* can also contain the content url to load. The format in the latter case is: url_identifier[;content].
* The content url is expected to be properly URL encoded.
* @param {String} pageId (optional) The URL identifier corresponding to the page to show.
*/
Environment.Navigation.goTo = function(navToken, pageId) {
// #37674: the tabView component does not provide a way to get the number of tabs,
// so try and retrieve the second one. If it does not exist, hide the component.
if (!tabView.getTab(1)) {
$('#environmentNavigation').hide();
}
var currentState = YAHOO.util.History.getCurrentState(ApplicationPortalUtils.navItemKey);
if (navToken === currentState) {
var navConfig = {};
var contentIndex = navToken.indexOf(';');
if (contentIndex < 0) {
navConfig.navItemId = navToken;
} else {
navConfig.navItemId = navToken.substring(0, contentIndex);
navConfig.content = navToken.substring(contentIndex + 1);
}
// Check if the nav item is valid. If it's invalid, it will try to default to
// the application's default nav item.
if (!navItemDefaultContent[navConfig.navItemId]) {
if (!navItemDefaultContent['system.defaultitem']) { // The application itself is either invalid or it might not have any nav items.
// The app doesn't have any content to load, so we manually need to invoke the
// "afterContentLoad" callback.
Environment.Navigation.afterContentLoad();
return;
}
var errorCallback = function() {
asi.alert('The specified page is not available.');
};
navConfig.navItemId = 'system.defaultitem';
}
tabView.set('activeIndex', navItemDefaultContent[navConfig.navItemId].index);
if (pageId) {
backgroundAction('/portal.do?$p=' + pageId, null, errorCallback);
} else if (!navConfig.content || StringUtils.isBlank(navConfig.content)) {
backgroundAction(navItemDefaultContent[navConfig.navItemId].url, null, errorCallback);
} else {
backgroundAction(navConfig.content, null, errorCallback);
}
} else {
YAHOO.util.History.navigate(ApplicationPortalUtils.navItemKey, navToken);
}
};
$('#environmentNavigation li').click(function(){
var navItem = this.getAttribute(ApplicationPortalUtils.navItemKey);
Environment.Navigation.goTo(navItem);
});
})();
</script>
<div id="environmentTitlebar">
<div style="position:relative">
<div id="inlineConfirmMessage" onclick="STATUS.hide();" title="Click to hide message" class="" style="display: none;">Inline confirmation message text goes here</div>
</div>
<div id="pageTitle">My Details</div>
<div id="pageContext"></div>
<div id="breadcrumb"></div>
<div class="links">
<div id="optionsToggleContainer" style="">
<a href="#" hidefocus="true">Actions</a>
</div>
</div>
<div id="pageOptionsMenu" class="yuimenu yui-module yui-overlay" style="z-index: 1; position: absolute; visibility: hidden; left: -10000px; top: -9999.41px;"><div class="bd"><ul class="first-of-type"><li class="yuimenuitem first-of-type" id="yui-gen3" groupindex="0" index="0"><a href="#" class="yuimenuitemlabel">Bookmark this page</a></li></ul></div><div class="yui-menu-shadow"></div></div>
</div>
<div id="environmentContent" lasthref="/portal.bg?appian_environment=apps&%24p=53" class="">
<div class="asiPortalPageHeader"><h1>My Details</h1>
</div>
<div class="asiToolbar" id="portalPageToolbar" style="display: none;">
<input id="secretPageName" type="hidden" value="My Details">
</div>
<div style="float: left; width: 70%;" id="leftColumn" class="portletColumn"><div id="portletContainer_178">
<a name="178"></a>
<div class="portlet portletPlain">
<div class="portletHeader viewerMode">
</div>
</div>
<div id="portletContainer_224">
<a name="224"></a>
<div class="portlet portletPlain">
<div class="portletHeader viewerMode">
</div>
<div class="portletBody">
<div class="portletError" id="portletError_224" style="display:none;"></div>
<div class="portletMessage" id="portletMessageBar_224" style="display:none;"></div>
<div id="miniWebForm_224" class="mini">
<div id="miniWebContent_224" style="display: none"><p><strong><font size="3"><a href="/suite/process/switchmodeldashboardordetails.bg?processModelId=643&showDashboard=true&appian_environment=" target="fProcess" rel="noopener noreferrer">Update My User Profile</a></font></strong></p>
<p><em>You can update your user contact details using this function.<br></em></p></div>
<iframe title="Web channel content" style="width: 100%; height: 35px;" frameborder="0" id="miniWebIframe_224" src="/suite/p_mini/viewMiniContent.do?chid=224&appian_environment=apps"></iframe>
</div>
</div>
</div>
</div>
<div id="portletContainer_232">
<a name="232"></a>
<div class="portlet portletPlain">
<div class="portletHeader viewerMode">
</div>
<div class="portletBody">
<div class="portletError" id="portletError_232" style="display:none;"></div>
<div class="portletMessage" id="portletMessageBar_232" style="display:none;"></div>
<div id="miniWebForm_232" class="mini">
<div id="miniWebContent_232" style="display: none"><p><strong><font size="3"><a href="https://myminesonline.business.qld.gov.au/suite/startprocess/resetpassword.popup?appian_environment=apps" target="_blank" rel="noopener noreferrer">Change My User Password</a> </font></strong></p>
<p><em>You can reset your MyMines Online password using this function.</em><br></p></div>
<iframe title="Web channel content" style="width: 100%; height: 35px;" frameborder="0" id="miniWebIframe_232" src="/suite/p_mini/viewMiniContent.do?chid=232&appian_environment=apps"></iframe>
</div>
</div>
</div>
</div>
<div id="portletContainer_108">
<a name="108"></a>
<div class="portlet portletPlain">
<div class="portletHeader viewerMode">
</div>
<div class="portletBody">
<div class="portletError" id="portletError_108" style="display:none;"></div>
<div class="portletMessage" id="portletMessageBar_108" style="display:none;"></div>
<div id="miniWebForm_108" class="mini">
<div id="miniWebContent_108" style="display: none"><p> </p>
<p><font size="5"><strong>Authorised holder representative (AHR) details <br></strong></font></p>
<hr>
<p></p>
<p></p></div>
<iframe title="Web channel content" style="width: 100%; height: 59px;" frameborder="0" id="miniWebIframe_108" src="/suite/p_mini/viewMiniContent.do?chid=108&appian_environment=apps"></iframe>
</div>
</div>
</div>
</div>
</div>
<div style="float: right; width: 29%;" id="rightColumn" class="portletColumn"><div id="portletContainer_112">
<a name="112"></a>
<div class="portlet portletDefault">
<div class="portletHeader">
I want to...
</div>
<div class="portletBody">
<div class="portletError" id="portletError_112" style="display:none;"></div>
<div class="portletMessage" id="portletMessageBar_112" style="display:none;"></div>
<div id="miniWebForm_112" class="mini">
<div id="miniWebContent_112" style="display: none"><p><a href="mailto:mines_online@dnrm.qld.gov.au" target="_blank" rel="noopener noreferrer">Contact the helpdesk</a></p>
<p><a href="https://myminesonline.business.qld.gov.au/help/Default_Left.htm" target="_blank" rel="noopener noreferrer">Open MyMinesOnline help</a><br></p></div>
<iframe title="Web channel content" style="width: 100%; height: 30px;" frameborder="0" id="miniWebIframe_112" src="/suite/p_mini/viewMiniContent.do?chid=112&appian_environment=apps"></iframe>
</div>
</div>
</div>
</div>
</div>
<br style="clear: both;">
<div style="clear: both; visibility: hidden;">.</div></div>
<script type="text/javascript">
(function(){
function updateCounter(containers, count) {
if(count > 0) {
containers.html(" ({0})".supplant(count));
} else {
containers.html("");
}
}
var tasksCount = parseInt('2');
var notificationsCount = parseInt('0');
var tasksSpan = $("#environmentHeader span.taskCount").add("#environmentNavigation span.taskCount");
var alertsSpan = $("#environmentHeader span.notificationCount").add("#environmentNavigation span.notificationCount");
updateCounter(tasksSpan, tasksCount);
updateCounter(alertsSpan, notificationsCount);
})();
</script>
<div style="clear:both; visibility:hidden;"> </div>
</div>
</div>
<iframe id="yui-history-iframe" style="display:none;" src="/suite/portal/blank.jsp" title="Background processing frame. No displayed content."></iframe>
<input id="yui-history-field" type="hidden">
<script>
(function initializeHistory(){
var initialTopNavViewState = YAHOO.util.History.getBookmarkedState(ApplicationPortalUtils.topNavKey);
if (StringUtils.isBlank(initialTopNavViewState)) {
// if no bookmarked state is available then use the top-navigation item determined by
// ApplicationsPortalEntryPoint as the default state; 'system.tasks' is used as last-resource
// fallback -it would only be used if the requested top-navigation item is invalid or not
// available; in which case we already present an error page.
var topNavItemId = 'myminesonline';
initialTopNavViewState = StringUtils.isBlank(topNavItemId) ? 'system.tasks' : topNavItemId;
}
// The registration of the application needs to happen before the registration of the
// tab navigation. When changing apps, we have to do a "multinavigate" to update
// both status, the status of the app and the navigation and YUI will trigger
// both of them. However, we just need to execute the application status change.
YAHOO.util.History.register(ApplicationPortalUtils.topNavKey, initialTopNavViewState, ApplicationPortalUtils.loadTopNavigation);
var initialNavItemState = YAHOO.util.History.getBookmarkedState(ApplicationPortalUtils.navItemKey) || ApplicationPortalUtils.defaultNavItem;
YAHOO.util.History.register(ApplicationPortalUtils.navItemKey, initialNavItemState, function(navId){
Environment.Navigation.goTo(navId);
});
YAHOO.util.History.onReady(function executeWhenPageIsFinishedLoading() {
// This function gets triggered after login or after a full page refresh.
// In the first case, there will not be a bookmarked state, we just need to go
// to the "initialNavItemState".
// In the second case, there might be a bookmarked state, if so, navigate to
// that state.
var bookmarkedTopNavState = YAHOO.util.History.getBookmarkedState(ApplicationPortalUtils.topNavKey);
if (StringUtils.isBlank(bookmarkedTopNavState)) {
Environment.Navigation.goTo(initialNavItemState);
} else {
ApplicationPortalUtils.loadTopNavigation(bookmarkedTopNavState);
}
});
YAHOO.util.History.initialize("yui-history-field", "yui-history-iframe");
})();
</script>
<div id="footer">
19.3.151 ©2003-2021 Queensland Government
</div>
<script type="text/javascript">
document.body.onclick= function (evt) {
evt = evt || event;
var target = evt.srcElement || evt.target;
try{ DATETIME.hideAll(target); } catch(e){}
try { hideAllReportPalettes(target, true); } catch(e){}
try{ DROPDOWN.hideAll(); } catch(e){}
try{ if(!(target.id in set('formPropertiesPaneLink','formPropertiesPaneImg'))){$("#formPropertiesPane").hide();}} catch(e){}
}
document.onmousedown = function (e) {
try { DIALOG.pick(e); } catch(e){}
}
document.onmousemove = function (e) {
try { DIALOG.move(e); } catch(e){}
}
document.onmouseup = function (e) {
try { DIALOG.drop(e); } catch(e){}
}
document.onmouseover = document.onmouseout = function () {
window.status = '';
return true;
}
window.onresize = function(){
if (AUTOCOMPLETE.pointer){ AUTOCOMPLETE.pointer.placeSuggestionGrid(); }
}
function hideLayers() {
try { STATUS.hide(); } catch(e){}
try { DIALOG.hide(); } catch(e){}
try { DATETIME.hideAll(); } catch(e){}
try { PICKER.hideAll(); } catch(e){}
asi.removeAlert();
}
document.onkeydown = function(e) {
e = e || event;
switch (e.keyCode) {
case ESC_KEY: hideLayers(); break;
case ENTER_KEY:
try { autoClick(getObject('asiAlertOK')); } catch(e){}
break;
}
return true;
}
function onfocus() {
if ((typeof processModelerLegacy != 'undefined' && processModelerLegacy.closed == true) ||
(typeof processModelerDesign != 'undefined' && processModelerDesign.closed == true)) {
if (window.PROCESS_MODEL_ID) {
backgroundPage("/process/unlockProcessModel.none?processModelId="+window.PROCESS_MODEL_ID);
} else if (window.PROCESS_ID) {
backgroundPage("/process/unlockProcessModel.none?processId="+window.PROCESS_ID);
}
document.body.onfocus=null;
}
if (typeof processModelerLegacy == 'undefined' && typeof processModelerDesign == 'undefined') {
document.body.onfocus=null;
}
}
</script>
<iframe src="javascript:''" id="masterapp" tabindex="-1" style="position: absolute; width: 0px; height: 0px; border: none;"></iframe><div aria-hidden="true" style="display: none;"></div><div class="appian-indicator-message" style="display: none;" aria-hidden="true"><span class="GE4QWF-BK-"><span class="GE4QWF-BJ-">Working...</span></span> <span class="GE4QWF-BL-">Working...</span></div><div style="position: absolute; height: 1px; width: 1px; top: -1000px; left: -1000px;"><span class="ygtvtm"> </span><span class="ygtvtmh"> </span><span class="ygtvtp"> </span><span class="ygtvtph"> </span><span class="ygtvln"> </span><span class="ygtvlm"> </span><span class="ygtvlmh"> </span><span class="ygtvlp"> </span><span class="ygtvlph"> </span><span class="ygtvloading"> </span></div></body>
答案 0 :(得分:1)
需要先切换到<frame>
,然后才能找到元素。
frame = driver.find_element_by_id("fContent")
driver.switch_to.frame(frame)
xpath = "//div[@id='environmentNavigation']//li/a[contains(., 'All permits')]"
tab = wait.until(EC.element_to_be_clickable((By.XPATH, xpath))
tab.click()
答案 1 :(得分:0)
尝试使用 javascript 点击:
import time
time.sleep(3)
el = driver.find_element_by_xpath('//li[@nav="allPermits"]')
driver.execute_script("arguments[0].click();", el)