我们如何单击Python Selenium中列表的图标(list'对象没有属性'单击错误)?
我正在一个RPA项目中,我正在尝试通过网站进行自动化。我正在尝试编写XPAD以单击我针对的对象(使用硒),但这是一个列表,我会收到此错误; “列表”对象没有属性'单击'我在我的代码下粘贴了检查部分的图像(SS)。
site = webdriver.Chrome("D:\\Users\\user\\Desktop\\chromedriver.exe")
site.get("websiteaddress")
site.find_elements_by_partial_link_text('Findings and Action').click()
而且最后一排的这是
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()
事先感谢您的帮助!
从浏览器(部分)检查:
<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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
find_elements_by_partial_link_text()函数返回所有发现元素的列表。
如果仅需要一个元素,则可以使用 find_element_by_partial_link_text()函数。
但是,如果您需要单击与定位器匹配的所有发现的元素,则可以使用:
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: