ElementClickInterceptedException: element click intercepted: [duplicate] - python

This question already has answers here:
Element MyElement is not clickable at point (x, y)... Other element would receive the click
(5 answers)
Closed 3 years ago.
I'm trying to submit one form on wordpress plugin using selenium + python. When I press publish button , it is giving an error.
ElementClickInterceptedException: element click intercepted: Element
type="submit" name="publish" id="publish" class="button button-primary button-large" value="Publish"> is not clickable at point (728, 15). Other element would receive the click:
...
I have tried following solutions:
Used action driver, but it didn't work.
Used webdriverwait() function, it didn't work.
Used Xpath, CSS selector, ID - It's giving same error in all three.
` browser.find_element_by_css_selector("""#save-post""").click()
WebDriverWait(driver, 90).until(EC.element_to_be_clickable((By.ID, "save-post"))).click()
`
Note that when I run that specific line in python console, it is working. But while running the full script, it is showing error.
There are so many similar questions on portal but none of them worked. Kindly help me to solve this issue.

Ok, the answer is in error message - "Other element would receive the click: ..."
I had the same problem when I just started using selenium.
Couldn't figure out what's the problem. "Other element would receive the click: ..." means there is other element above(overlapping) your element(pop up window, page is grayed out or disabled while loading, Some JS running etc., so when Selenium trying to click on your element its actually clicking on that blocking element.
Selenium is running really fast and clicking before its become clickable, that's why u are not able to click on it - "when I run that specific line in python console, it is working" Try to click after time.sleep() 5-10 sec or run script with debug mode.
If this is the case then you can use wait or add condition before find your element to check that element that prevent from clicking on you element is not there then u click on your element.

Related

No xpath click in selenium

I've written a "Lovoo" bot with Python and Selenium and I'm almost done.
Now I have the following problem:
When the bot clicks on a user, a window opens. To exit this window, the bot has to click outside of it.
But from that point on all the source code has changed and I have nowhere to xpath or click with selenium. I simply can't get any xpath that works.
I tried
WebDriverWait(DRIVER,10).until(EC.element_to_be_clickable((By.XPATH,'//body[1]')))
DRIVER.find_element_by_xpath('//body[1]).click()
But the click is only working randomly and rarely.
Error:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <div class="thumbnail thumbnail-square u-margin-0">...</div> is not clickable at point (370, 497). Other element would receive the click: <div class="absolute-fill text-left" ng-transclude=""></div>
(Session info: chrome=96.0.4664.9)
I don't want to use
action.click()
because then I won't be able to use my mouse for other things.
If I understood it clearly, you are trying to click on co-ordinate rather than a web element.
If this is the case then you can define an offset like below and try to click on it.
from selenium.webdriver.common.action_chains import ActionChains
ActionChains(driver).move_by_offset(10,10).click().perform()

Python selenium code just stopped working [duplicate]

This question already has answers here:
Element MyElement is not clickable at point (x, y)... Other element would receive the click
(5 answers)
Closed 2 years ago.
I have been testing some code today and it has been working totally fine. It has now just stopped working, I haven't changed anything.
action.move_to_element(text_box)
action.click(text_box)
action.send_keys(index)
action.perform()
sleep(1)
driver.find_element_by_xpath('//*[#id="AC_tRes"]/li[1]').click()
sleep(10)
link = driver.find_element_by_link_text('Financials')
link.click()
This code enters a name into a search box and then goes to that page. It should then click on the Finance page.
It has been working totally fine. I haven't changed anything and now I get the following error:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <a class="link3" href="foo" </a> is not clickable at point (505, 509)
But I don't understand why it would just stop when I haven't even edited the code.
https://www.marketscreener.com/MICROSOFT-CORPORATION-4835/
I land on this page and it should go to the Financial link. but it is sometimes working sometimes giving me the above error.
Sometimes site can take a while to load, way exceeding your sleep(10) call. Hence, the element might not be available for clicking when the line is executed.
You will want to read the docs on Waits, particularly around Expected Conditions, and rebuild your navigation with that mindset.

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable at point [duplicate]

This question already has answers here:
Element MyElement is not clickable at point (x, y)... Other element would receive the click
(5 answers)
Closed 3 years ago.
in this case, I use the argument (--headless) of chrome webdriver, the error message will happened
my code is
chrome_options.add_argument('--headless')
if I give up the 'headless' option, the chrome will starup , and everting is going well, no error, and could continue running all the time
and every time, the error will happen at this code, it is a loop running function, totally 17 time, but will happen at the 4th time.
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,'_tmp_'))).click()
without headless, everything is working perfectly, with headless, always stuck here, cannot understand why
You can perform JavaScriptExecutor click on the element as it directly performs the action on the div and is not affected by the position of the element on the page or the headless option.
You can do it like:
button = driver.find_element_by_xpath("_tmp_")
driver.execute_script("arguments[0].click();", button)

Locate "file upload" button with Selenium

I have the button shown below (image and HTML) and am trying to click it.
Selenium is unable to locate it - I have tried locating by both xpath and by ID.
<input id="wsUpload1" type="file" name="file">
XPATH:
element = driver.find_element_by_xpath('//input[#id="wsUpload1"]')
element.click()
Where am I going wrong?
EDIT: Here is the exception thrown by Selenium:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[#id="wsUpload1"]"}
Possibilities
Duplicate web element with same id in the page.
Element may be in frame. You need to switch to frame
Trying to access the web element before page is loading.Give some wait time.
Not sure why your button wasn't found, maybe it's because of quotes (although it should show you error in that case), try with driver.find_element_by_xpath(".//input[#id='wsUpload1']") and see if it works. I'm not sure is your button already rendered on the page or you trigger it somehow so it's not there yet?
NoSuchElementException is thrown because your targeted element couldn't be found on that page, it could be that you are on the wrong page, element is not rendered yet so you should wait for it to appear, element could be in some iframe etc etc, it's hard to say when I don't know how your page works.
But if you are trying to upload something you should perform sendKeys() on that button (with path of file which are you trying to upload), not click() on it. This is how selenium upload works.
I have solved it - the driver opens a tab on a side panel and the button is in the tab. There seems to be a few ms delay between clicking the tab and the button appearing so I added a wait until element is clickable and that seems to work.
wait.until(EC.element_to_be_clickable((By.XPATH, "//input[#id='wsUpload1']"))).click()

Python Webdriver need code to find and click a particular element

This is a similar question to one answered for me earlier.
I have used Python 2.7, Webdriver and Chrome to access Pinterest to insert images to a board. I have successfully logged in to the site and created a board. The problem that I have is to identify and click the “Edit Board” button successfully using xpath find elements code. I attach an image of the web page (see red arrow) and the Chrome inspect on the element. The code I have tried is:
driver.find_element_by_xpath('//span[contains(text(),"Edit board")]')
The result is enabled and displayed, however, click on the element gives the following exception:
WebDriverException: Message: unknown error: Element is not clickable
at point (131, 91). Other element would receive the click: <button
class="Button Module ShowModalButton boardEditButton btn hasIcon
rounded" type="button">...</button>
I cannot see any other find element option which will make the button unique.
I have successfully used the span text find on this website in one other place. It does not work for all buttons of this type, but, in those cases another unique tag qualifier works.
Web Page:
Inspect Element:

Categories