我正在尝试在耐克网店结账,但我已经尝试了一切并进行了搜索,但仍找不到答案。
https://www.nike.com/nl/nl/checkout/tunnel
我已经做了以下工作:
driver.find_element_by_xpath('//button[@id="qa-guest-checkout-mobile"]').click()
<button id="qa-guest-checkout-mobile" aria-label="Guest Checkout"
class="ncss-btn-accent u-rounded u-full-width ncss-brand u-uppercase pt3-sm pt2-lg pr5-sm pb3-sm pb2-lg pl5-sm fs14-sm d-lg-h">
<span class="d-sm-ib va-sm-m mr1-sm">Afrekenen als bezoeker</span></button>
我曾尝试使用“按ID查找”、“CSS”等方法,但都不起作用。我在这里做错了什么?当我打印元素时,只会得到一个元素,并且没有报错。
File "C:\Users\X\OneDrive\Desktop\SN\NA.py", line 23, in <module>
test = driver.find_element_by_xpath('//button[@id="qa-guest-checkout-mobile"]').click()
File "C:\Users\X\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Users\X\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "C:\Users\X\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\X\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: element not interactable
(Session info: chrome=74.0.3729.131)
(Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.17134 x86_64)
.click()
进行单击与使用JavaScript进行单击的区别,就像本答案所使用的那样。希望能有所帮助! - Reedinationer