'How can we click on an icon which is list in Python Selenium ('list' object has no attribute 'click' error)?
I am on an RPA project and I am trying an automation via a website. I am trying write xpad to click on the object I aim (with selenium) however it is a list and I get this error; ''list' object has no attribute 'click'' I paste the inspect part's image (ss) here and below my code.
site = webdriver.Chrome("D:\\Users\\user\\Desktop\\chromedriver.exe")
site.get("websiteaddress")
site.find_elements_by_partial_link_text('Findings and Action').click()
and also this one for the last row
fa = site.find_elements_by_xpath("//ul[@class='sasLeftNavNav']//li[.//span[text()='RGF_HUB_Home_MRM_appContainer_lfn_5_icn']]/li[@id='RGF_HUB_Home_MRM_appContainer_lfn_5']")
fa.click()
Thank you in advance for the help !
inspect from the browser (partial):
<li id="RGF_HUB_Home_MRM_appContainer_lfn_5" role="menuitem" data-item="5" aria-label="Selected, Findings and Action" tabindex="0" class="sasLeftNavItemSelected" aria-selected="true"><span id="RGF_HUB_Home_MRM_appContainer_lfn_5_icn" data-sap-ui="RGF_HUB_Home_MRM_appContainer_lfn_5_icn" data-item="5" role="presentation" aria-hidden="true" aria-label="Findings and Action" title="Findings and Action" data-sap-ui-icon-content="" class="sapUiIcon" style="font-family:'sas-icons'"></span><span class="sasLeftNavItemState" id="RGF_HUB_Home_MRM_appContainer_lfn_5_state" data-item="5"></span><span class="sasLeftNavItemLabel" title="Findings and Action" data-item="5">Findings and Action</span></li>
<span id="RGF_HUB_Home_MRM_appContainer_lfn_5_icn" data-sap-ui="RGF_HUB_Home_MRM_appContainer_lfn_5_icn" data-item="5" role="presentation" aria-hidden="true" aria-label="Findings and Action" title="Findings and Action" data-sap-ui-icon-content="" class="sapUiIcon" style="font-family:'sas-icons'"></span>
<::before></::before>
Solution 1:[1]
find_elements_by_partial_link_text() function returns list of all found elements. If you need just one element you can use find_element_by_partial_link_text() function.
However if you need to click to all of found elements matching your locator then you can use:
for element in site.find_elements_by_partial_link_text('Findings and Action'):
element.click()
Solution 2:[2]
<html class="sap-desktop sapUiTheme-sas_corporate sapUiMedia-Std-Desktop sapUiMedia-StdExt-Desktop" dir="ltr" data-sap-ui-browser="cr99" data-sap-ui-os="win10" lang="en" data-sap-ui-animation="on"><head><base href="/SASRiskGovernanceFramework/">
<script type="text/javascript" src="resources/sap/ui/thirdparty/signals.js"></script>
<script type="text/javascript" src="resources/sap/ui/thirdparty/hasher.js"></script>
<style>
.gshHeader {
border-color: #ec66eb;
font-size: 11;
margin-bottom: 4;
}
.gshDisplay {
border-color: #6878b6;
font-size: 10;
margin-bottom: 19;
}
</style>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="icon" type="image/x-icon" href="https://imodel.ic.ing.net:8343/SASRiskGovernanceFramework/resources/shcb1643626187000/themes/sas/hc/ui/commons/themes/sas_corporate/img/ico/SASLogo_toolbar.ico">
<meta content="https://imodel.ic.ing.net:8343/SASRiskGovernanceFramework/resources/shcb1643626187000/themes/sas/hc/ui/commons/themes/sas_corporate/img/ico/SASLogo_toolbar.ico" itemprop="image">
<link rel="stylesheet" href="https://imodel.ic.ing.net:8343/SASRiskGovernanceFramework/resources/shcb1643626187000/themes/sas/hc/ui/commons/themes/sas_corporate/splash.css" media="screen">
<meta charset="UTF-8">
<style type="text/css">.gshDisplay { border-color: #6878af; font-size: 14; margin-bottom: 11; }</style><script src="https://imodel.ic.ing.net:8343/SASRiskGovernanceFramework/resources/shcb1643626187000/sap/ui/core/library-preload.js" data-sap-ui-module="sap/ui/core/library-preload.js"></script><script src="https://imodel.ic.ing.net:8343/SASRiskGovernanceFramework/resources/shcb1643626187000/sas/hc/ui/core/library-preload.js" data-sap-ui-module="sas/hc/ui/core/library-preload.js"></script><link type="text/css" rel="stylesheet" href="https://imodel.ic.ing.net:8343/SASRiskGovernanceFramework/resources/shcb1643626187000/themes/sap/ui/core/themes/sas_corporate/library.css" id="sap-ui-theme-sap.ui.core" data-sap-ui-ready="true"><link type="text/css" rel="stylesheet" href="https://imodel.ic.ing.net:8343/SASRiskGovernanceFramework/resources/shcb1643626187000/themes/sas/hc/ui/core/themes/sas_corporate/library.css" id="sap-ui-theme-sas.hc.ui.core" data-sap-ui-ready="true"><title>ING iModel (powered by SAS® Model Risk Management)</title></head>
<body class="sapUiBody">
<style>
#sas-hc-splash-alertText {
position: absolute;
clip: rect(0px,0px,0px,0px);
}
</style>
<script id="hc-config">
(function(){
window['sap-ui-config'] = window['sap-ui-config'] || {};
var config = window['sap-ui-config'];
config.sas = config.sas || {};
config.sas.contextPath='https://imodel.ic.ing.net:8343/SASRiskGovernanceFramework';
config.sas.appId='SASApplicationSwitcherBootstrap';
config.language='tr-tr';
config.rtl=false;
config.sas.crossDomainProxy='CASedCrossDomainProxy';
config.sas.commonsRegistryUrl='https://imodel.ic.ing.net:8343/SASRiskGovernanceFramework/rest';
config.sas.wipRegistryUrl='https://imodel.ic.ing.net:8343/SASWIPClientAccess/rest/services';
config.sas.servicePlatform='WIP';
config.sas.themeUrl='https://imodel.ic.ing.net:8343/SASRiskGovernanceFramework/resources/shcb1643626187000/themes';
config.sas.webdocUrl='https://imodel.ic.ing.net:8343/SASWebDoc';
config.sas.softwareComponentName='Risk Gov Frwk Mid-Tier';
config.sas.applicationSwitcherEnabled=true;
config.sas.sessionTimeoutUrl='https%3A%2F%2Fimodel.ic.ing.net%3A8343%2FSASLogon%2FTimedOut.do%3F_locale%3Dtr_TR%26_sasapp%3DRisk%2BGov%2BFrwk%2BMid-Tier%26rgfContentId%3Dmrm';
config.sas.sessionMaxInActiveInterval=1800;
config.sas.sessionTimeoutWarningDuration=300;
config.sas.userCapabilities='';
config.sas.appName = 'ING iModel (powered by SAS\u00AE Model Risk Management)';
config.theme = config.theme || 'sas_corporate';
config.themeroots = config.themeroots || {};
config.themeroots[config.theme] = config.themeroots[config.theme] || 'https://imodel.ic.ing.net:8343/SASRiskGovernanceFramework/resources/shcb1643626187000/themes';
}());
</script>
<script id="hc-precore" src="https://imodel.ic.ing.net:8343/SASRiskGovernanceFramework/resources/shcb1643626187000/sas/hc/ui/core/preCore.js" data-loading="Yükleniyor" data-still-loading="Halen Yükleniyor"></script> <script>
(function(){
var config = window['sap-ui-config'];
config.modules = ['sas.hc.ui.core.library'];
config.sas.bootTask = undefined;
}());
</script>
<script src="https://imodel.ic.ing.net:8343/SASRiskGovernanceFramework/resources/shcb1643626187000/sap-ui-core.js" id="sap-ui-bootstrap"></script>
<script type="text/javascript" id="hc-init">
sap.ui.getCore().attachInit(function(){
sas.log.info("appSwitcher"+sas.applicationSwitcher);
sas.applicationSwitcher.localizedStrings['discardUnsavedChanges.txt']='De\u011Fi\u015Fiklikleri atmak ve uygulamalardan \u00E7\u0131kmak m\u0131 istiyorsunuz?';
sas.applicationSwitcher.localizedStrings['unsavedChangesNotification.txt']='A\u015Fa\u011F\u0131daki uygulamalarda kaydedilmemi\u015F de\u011Fi\u015Fiklikler bulunuyor:';
$( window ).on('beforeunload',function(event){
if(sas.applicationSwitcher.isDirtyMessageEnabled()===false)
return;
var unsavedChangesMessage=sas.applicationSwitcher.getUnsavedChangesMessage();
if(unsavedChangesMessage===null){
return;
}
else{
event.returnValue=unsavedChangesMessage;
return unsavedChangesMessage;
}
});
sas.applicationSwitcher.gotoApp('RGF_HUB_Home_MRM', window.location.href, true, {'bootstrapping':true});
});
</script>
<div id="appsContainer" style="position: absolute; overflow: hidden; top: 0px; left: 0px; width: 100%; height: 100%;"><iframe id="RGF_HUB_Home_MRM_iframe" loaded="false" allowfullscreen="true" tabindex="0" src="https://imodel.ic.ing.net:8343/SASRiskGovernanceFramework/content/mrm?launchedFromAppSwitcher=true" style="width: 100%; height: 100%; border-width: 0px;"></iframe></div></body></html>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | pL3b |
Solution 2 | Celine07 |