Error "Other element would receive the click" in Python
Element on which you are trying to click has been covered by some other element so that other element getting the click instead of the actual element.
There may be following possibilities that actual element not getting clicked:
Case 1. lets say if its a loader which comes while your element getting load and get invisible after some time.
Solution: Here you have to wait until the loader get invisible and then have to perform click on actual element
from selenium.webdriver.support import expected_conditions as EC wait = WebDriverWait(driver, 10) element = wait.until(EC.invisibility_of_element_located((By.ID, 'loader_element_id'))) element_button = wait.until(EC.element_to_be_clickable((By.ID, 'your_button_id'))) element_button.click()
Case 2. actual element is not visible within browser dimension and covered by some overlay element.
Solution: Here you need to scroll to the required element and then have to perform the click
from selenium.webdriver.common.action_chains import ActionChains element = driver.find_element_by_id("your_element_id") actions = ActionChains(driver) actions.move_to_element(element).perform()
OR use can use
execute_script
like :driver.execute_script("arguments[0].scrollIntoView();", element)
OR perform the click using JavaScript.
driver.execute_script("arguments[0].click();", element)
Note: Please make necessary correction as per Python syntax if require.
You may use action class to click your element,
from selenium.webdriver import ActionChainsactions = ActionChains(driver)actions.move_to_element(element).click().perform()
As per the HTML and your code trials you have attempted to click on the <span>
tag in stead you should try to invoke click()
on the <a>
tag as follows:
Using
css_selector
:element = WebDriverWait(driver, 30).until(lambda x: x.find_element_by_css_selector("div.loading a[onclick^='get_more']"))element.click()
Using
xpath
:element = WebDriverWait(driver, 30).until(lambda x: x.find_element_by_xpath("//p[@class='btn blue']/span[contains(.,'さらに表示')]//following::a[contains(@onclick,'get_more')]"))element.click()