简体   繁体   English

EASY PYTHON SELENIUM:如何点击 class 名称?

[英]EASY PYTHON SELENIUM: How do I click by class name?

Goal: Click by class name.目标:按 class 名称单击。

HTML: HTML:

<span class="Icon-Svg Link-Icon-Svg next-Link-Icon-Svg Pagination-RightControl-Link-Icon-Svg Pagination-Page-Link-Icon-Svg" 

style="-webkit-mask-image: url(&quot;https://[REDACTED]/icon/ArrowRight.svg&quot;); -webkit-mask-size: contain; -webkit-mask-repeat: no-repeat; -webkit-mask-position: center center;"></span>

Attempt:试图:

driver.find_element(By.CLASS_NAME, 'Icon-Svg Link-Icon-Svg next-Link-Icon-Svg Pagination-RightControl-Link-Icon-Svg Pagination-Page-Link-Icon-Svg')

Screenshot of HTML HTML截图

Element you are trying to locate here having multiple class names.您试图在此处找到具有多个 class 名称的元素。 Such element can be located by XPATH or CSS_SELECTOR while By.CLASS_NAME supports single class name only, so instead of此类元素可以通过 XPATH 或 CSS_SELECTOR 定位,而By.CLASS_NAME仅支持单个 class 名称,因此而不是

driver.find_element(By.CLASS_NAME, 'Icon-Svg Link-Icon-Svg next-Link-Icon-Svg Pagination-RightControl-Link-Icon-Svg Pagination-Page-Link-Icon-Svg')

you can use您可以使用

driver.find_element(By.CSS_SELECTOR, 'span.Icon-Svg.Link-Icon-Svg.next-Link-Icon-Svg.Pagination-RightControl-Link-Icon-Svg.Pagination-Page-Link-Icon-Svg')

Please pay attention that locator you are using looks not too much reliable, you possibly could improve it.请注意,您使用的定位器看起来不太可靠,您可以改进它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 简单:如何使用 Selenium Webdriver 分离由 class 名称抓取的元素? - EASY: How do I separate elements grabbed by class name using Selenium Webdriver? 如何找到我用类名找到的元素的 ID (Python Selenium) - How do I find IDs of a elements I found with class name (Python Selenium) 如何使用 python 中的 selenium 从 class 名称中获取值? - How do I get a value from a class name using selenium in python? how do I select xpath image without a class name using selenium in python? - how do I select xpath image without a class name using selenium in python? EASY Python Selenium:如何下载位于“检查”&gt;“网络”下的 .mp4 文件? - EASY Python Selenium: How do I download an .mp4 file located under Inspect > Network? Selenium:我如何比较来自相同类型 class 名称的值并单击使用 python 值最高的链接 - Selenium: How can i compare values from same type class name and click the link with highest value using python 如何向上滚动,然后使用Selenium和python单击 - How do I scroll up and then click with Selenium and python 如何在Python中使用Selenium单击按钮? - How do I click a button using Selenium in Python? python3如何使用硒单击下拉框 - python3 How do I click dropdown box using selenium 如何使用 Selenium 和 Python 2.7 单击表单中的按钮? - How do I click a button in a form using Selenium and Python 2.7?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM