par*_*rik 42 python selenium web-scraping selenium-firefoxdriver selenium-webdriver
我试图通过Selenium 刮掉这个网站.
我想点击"下一页"按钮,为此我这样做:
driver.find_element_by_class_name('pagination-r').click()
Run Code Online (Sandbox Code Playgroud)
它适用于许多页面但不适用于所有页面,我收到此错误
WebDriverException: Message: Element is not clickable at point (918, 13). Other element would receive the click: <div class="linkAuchan"></div>
Run Code Online (Sandbox Code Playgroud)
总是为这个页面
我读了这个问题
我试过这个
driver.implicitly_wait(10)
el = driver.find_element_by_class_name('pagination-r')
action = webdriver.common.action_chains.ActionChains(driver)
action.move_to_element_with_offset(el, 918, 13)
action.click()
action.perform()
Run Code Online (Sandbox Code Playgroud)
但我得到了同样的错误
Rem*_*coW 90
另一个元素是覆盖要单击的元素.您可以execute_script()
用来点击它.
element = driver.find_element_by_class_name('pagination-r')
driver.execute_script("arguments[0].click();", element)
Run Code Online (Sandbox Code Playgroud)
Dee*_*rud 13
我有一个类似的问题,使用ActionChains没有解决我的错误:WebDriverException:消息:未知错误:元素不可点击点(5 74,892)
如果您不想使用execute_script,我找到了一个很好的解决方案:
from selenium.webdriver.common.keys import Keys #need to send keystrokes
inputElement = self.driver.find_element_by_name('checkout')
inputElement.send_keys("\n") #send enter for links, buttons
Run Code Online (Sandbox Code Playgroud)
要么
inputElement.send_keys(Keys.SPACE) #for checkbox etc
Run Code Online (Sandbox Code Playgroud)
小智 7
由于元素在浏览器上不可见,首先您需要向下滚动到可以通过执行 javascript 执行的元素。
element = driver.find_element_by_class_name('pagination-r')
driver.execute_script("arguments[0].scrollIntoView();", element)
driver.execute_script("arguments[0].click();", element)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
34422 次 |
最近记录: |