[英]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("https://[REDACTED]/icon/ArrowRight.svg"); -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')
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.