ElementClickInterceptedException Selenium unable to click button Python [duplicate] - selenium

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'm writing a selenium test that clicks on a specific button on a page. There are no other buttons present on the page but it seems like it's been obstructed so the codes unable to find it.
I've tried to maximum the page in the hope it can find the button but it's unable to do so
My code
driver.maximize_window()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[#id='save' and #name='save'][#value='View Report']"))).click()
copy of the element
<input type="submit" value="View Report" id="save" name="save" data-reportid="108">
Error
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable at point (1750, 770). Other element would receive the click: ...
(Session info: chrome=83.0.4103.116)

I think that another element may be overlapped your element, and you should wait for the invisibility of this layer. The layer can be a loading frame or anything else.
WebDriverWait(driver, 20).until(EC.invisibility_of_element((By.CSS_SELECTOR, "selector_for_ovelapped_layer")))
and then click the element you needed
Also, you can use Actions:
element = driver.find_element_by_xpath("//input[#id='save' and #name='save'][#value='View Report']")
webdriver.ActionChains(driver).move_to_element(element).click(element).perform()
And you can do this with JSExecutor:
element = driver.find_element_by_xpath("//input[#id='save' and #name='save'][#value='View Report']")
driver.execute_script("arguments[0].click();", element)

Related

What would be the cause of clicking failure in selenium for this checkbox?

I have a page as this,
And I want to click the top checkbox, which by default, would automatically select all the checkboxes in that list. As you can see, I have created the xpath value, and it matches the checkbox area that I want to pick. But when I was to have it executed in selenium, the checkbox checking never happens.
xpath_var = "//th[#class='selection-cell-header']/div[1]/input[1]"
WebDriverWait(self.driver, 30).until(
EC.element_to_be_clickable((By.XPATH, xpath_var,))).click()
And here is the exception I have received:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <input class="ftnt-checkbox" readonly="" type="checkbox" id="" value=""> is not clickable at point (305, 162).
Other element would receive the click: <label for="ftnt-checkbox"></label>
Any idea what could be wrong ? work around for such case? Manual clicking was ok, in that case.
Thanks,
Chun
The exception message indicates that there is another element that will receive the click. This is a kind of protection in Selenium.
You can try to click this label that is on top of your element. Or click the parent div. Or click your element with JavaScript.
WebElement element = driver.findElement(By.id("gbqfd"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);
Reference:
How to click an element in Selenium WebDriver using JavaScript?

How do I "get" an element from the HTML that is a "data-index" on Selenium IDE webdriver (Chrome)?

I want to do a click on somethink in a website, but the problm is that I get an error: Element <td style="">...</td> is not clickable at point (366, 304). Other element would receive the click: <div class="fixed-table-loading" but where I want to click, does not have a class, it only have's a data-index what can I use to "click" on it ?
You can use below css selector for finding that element,
tr[data-index='0']
However the error "Element <td style="">...</td> is not clickable at point (366, 304). Other element would receive the click: <div class="fixed-table-loading"" you are getting is not means that you doing false operation, it means that where selenium find your desired element to click, there is already a different element on that position and it will be getting that click.
So, first you need to focus on your element or if it is a member of a dropdown or opening list you need to first open that dropdown and then you should have click your element.

Navigation error in Selenium: Link is not clickable at point (...). Other element would receive the click [duplicate]

This question already has answers here:
Can not click on a Element: ElementClickInterceptedException in Splinter / Selenium
(7 answers)
ElementClickInterceptedException: Message: element click intercepted Element is not clickable error clicking a radio button using Selenium and Python
(1 answer)
ElementClickInterceptedException: Message: element click intercepted: Element <label> is not clickable with Selenium and Python
(2 answers)
Closed 2 years ago.
I would like to have Selenium navigate thorught the items of a navbar of this page, then retrieve its contents and pass them to beatifulsoup.
My code works fine for the first page, after which I get the following error:
ElementClickInterceptedException: Message: element click intercepted: Element ... is not clickable at point (77, 73). Other element would receive the click: <div class="fc-dialog-overlay"></div>
Previous answers have not helped.
Here is my code. I would truly appreciate any help.
webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--incognito')
options.add_argument('--headless')
driver = webdriver.Chrome(options=options)
target_page = 'https://www.rollingstone.com/music/music-lists/500-greatest-songs-of-all-time-151127/'
driver.get(target_page)
header = driver.find_element_by_id('pmc-gallery-list-nav-bar-render')
items = header.find_elements_by_tag_name('a')
songs = []
for item in items:
driver.maximize_window()
time.sleep(5)
item.click()
page_source = driver.page_source
soup = BeautifulSoup(page_source)
song_all = soup.find_all('h2', {'class':'c-gallery-vertical-album__title'})
for song in song_all:
songs.append(strip_extra_chars(song.get_text()))
driver.quit()
Let's comment options.add_argument('--headless') and see how program runs.
You need to identify which element overlap your link.
For example, I tried to run your code and this dialog apears:
In this case, to disable notification you can add:
prefs = {"profile.default_content_setting_values.notifications": 2}
options.add_experimental_option("prefs", prefs)
But this dialog doesn't match .fc-dialog-overlay locator so probably your problem with another element. You need to find it.
Another solution, you can click using js driver.execute_script()

WebDriverException Element is not clickable in Selenium [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 4 years ago.
Here is the error message:
org.openqa.selenium.WebDriverException: unknown error: Element <div class="col-md-2 col-sm-2 hidden-xs days" id="lblday3">...</div> is not clickable at point (799, 308). Other element would receive the click: <div class="modal-body text-center">...</div>
(Session info: chrome=69.0.3497.100)
Hi everyone, the above exception was thrown in my ThankYou page in my project. I've tried to change the wait time but it also doesn't work. Below is the method I used.
public void Clickthankyou() throws InterruptedException
{
if(driver.findElement(By.xpath("//*[#id='id_appoint']/h2")).isDisplayed())
{
WebDriverWait wait = new WebDriverWait(driver, 6);
WebElement elem =wait.until(ExpectedConditions.elementToBeClickable(Dateselect));
if(elem.isDisplayed())
{
elem.click();
}
Thread.sleep(2000);
driver.findElement(Clickbook).click();
}
else
{
driver.navigate().back();
}
The basic reason of this exception is due to ViewPort of Browser window which is seen by the user.
You need to scroll to specific element then click on it.
Key thing is element is not visible so not eligible for clicking.
ok use this code for do the fix using JavascriptExecutor ,
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeAsyncScript('arguments[0].scrollIntoView(true)', driver.findElement(By.xpath("//*[#id='id_appoint']/h2")))
js.executeAsyncScript('window.scrollBy(0,-150)')
or you can also do same using Actions class.
new Actions(driver).moveToElement(driver.findElement(By.xpath("//*[#id='id_appoint']/h2"))).click().perform();
Possible duplicate of Debugging "Element is not clickable at point" error

Selenium webdriver: checkbox element is not clickable [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.
I try to select checkbox via chrome webdriver, but always get error like "Element is not clickable at point (x, y)". I use the latest ChromeDriver 2.35. Thanks for help!
Here are the calls I have tried"
driver.findElement(By.xpath("/html[#class='ng-scope']/body[#class='layout-default']/main[#class='container']/form[#class='form-horizontal ng-pristine ng-valid ng-valid-required']/div[#class='row ng-scope']/div[#class='col-md-7']/div[#class='panel panel-default ng-scope']/div[#class='panel-body'][1]/div[#class='list-permission'][1]/div[#class='checkbox'][1]/label")).click();
OR
driver.findElement(By.cssSelector("input[value='platform:AccessWebsite']")).click();
OR
driver.findElement(By.xpath("//input[#value='platform:AccessWebsite']")).click;
Here is the snippet of html source
<h2>Main Platform</h2>
<div class="list-permission">
<div class="checkbox">
<label>
<input name="Policy[0][Action][]" type="checkbox" value="platform:AccessWebsite">
Access to the website
</label>
</div>
.......
When the element is not in a visual portion of the screen, then we will get element not clickable exception. The solution for this is moving the cursor to that element or scrolling the screen.You can use Actions class to move to that element or javascript executor for scrolling. try the below code and let me know.
WebElement element=driver.findElement(By.xpath("/html[#class='ng-scope']/body[#class='layout-default']/main[#class='container']/form[#class='form-horizontal ng-pristine ng-valid ng-valid-required']/div[#class='row ng-scope']/div[#class='col-md-7']/div[#class='panel panel-default ng-scope']/div[#class='panel-body'][1]/div[#class='list-permission'][1]/div[#class='checkbox'][1]/label"));
Actions act= new Actions(driver);
act.moveToElement(element).click().build().perform();
This should work as expected.
Note: some browsers may not support actions class, in such case i suggest you to scroll the screen and perform click.