Click to report an error
When using selenium, click events are triggered, and the following exceptions are often reported:
Element is not clickable at point
Causes and Solutions
There are four reasons
1. Not loaded
Wait for the element to be loaded before proceeding
you can use the python library
import time
time.sleep(3)
But it’s better to use selenium’s own webdriverwait
from selenium.webdriver.support.ui import WebDriverWait
WebDriverWait(driver, 10).until(EC.title_contains("element"))
For the specific usage of webdriverwait, please click the reference document
2. In iframe
If the element is in the iframe, you can’t find it in the window, and you can’t click it. So, switch to iframe to find the element
driver.switch_to_frame("frameName") # Switching by frame name
driver.switch_to_frame("frameName.0.child") # child frame
driver.switch_to_default_content() # return
For other related switching, please click the reference document
3. Not in the window, need to pull the scroll bar
The list page of many websites does not return all the contents immediately, but is displayed according to the view. Therefore, we need to drag the scroll bar to display the content to be obtained in the window
page = driver.find_element_by_partial_link_text(u'next page')
driver.execute_script("arguments[0].scrollIntoView(false);", page)
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT, u'next page'))).click()
About the contents of the drop-down scroll bar, please refer to the blog
4. The element to be clicked is covered
You can use the event chain to solve
problems, such as drop-down menus, which can be displayed through the hover, and then you can click
menu = driver.find_element_by_css_selector(".nav")
hidden_submenu = driver.find_element_by_css_selector(".nav #submenu1")
ActionChains(driver).move_to_element(menu).click(hidden_submenu).perform()
For details of the event chain, please click document
Similar Posts:
- [Solved] Selenium Error: ElementClickInterceptedException
- Iframe Cross-port Blocked a frame with origin from accessing a cross-origin frame
- Selenium: How to Solve Staleelementreferenceexception error (Three Methods)
- [Solved] document.onmousemove Error: Invalid or unexpected token
- How to Solve stale element reference: element is not attached to the page document
- How to Close the iframe Window opened by layui
- The difference between Top.location and window.location.href
- InvalidSelectorError: Compound class names not permitted [How to Solve]
- window.location And window.open The difference between
- [Solved] Element-ui Error: [Vue warn]: Invalid prop: type check failed for prop “index”. Expected String with value “1”, got Number with value 1