Skip to content

Commit

Permalink
Added ElementClickInterceptedException to all languages (#1914)[deplo…
Browse files Browse the repository at this point in the history
…y site]

* removed hanging badge code

* added ElementClickInterceptedException to all languages

* reduced line count, added reference

* Update _index.ja.md

* Update _index.pt-br.md

* Update _index.zh-cn.md

* Update _index.en.md

---------

Co-authored-by: Sri Harsha <[email protected]>
  • Loading branch information
shbenzer and harsha509 authored Sep 12, 2024
1 parent 314fb76 commit 799d3c4
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ Elements do not get relocated automatically; the driver creates a reference ID f
has a particular place it expects to find it in the DOM. If it can not find the element
in the current DOM, any action using that element will result in this exception.

### Common Causes
### Likely Cause

This can happen when:

* You have refreshed the page, or the DOM of the page has dynamically changed.
* You have navigated to a different page.
* You have switched to another window or into or out of a frame or iframe.

### Common Solutions
### Possible Solutions

**The DOM has changed**

Expand Down Expand Up @@ -98,14 +98,50 @@ You can't just relocate it from the current context,
and you can't switch back to an active context where it is valid. If this is the reason
for your error, you must both navigate back to the correct location and relocate it.

## ElementClickInterceptedException

This exception occurs when Selenium tries to click an element, but the click would instead be received
by a different element. Before Selenium will click an element, it checks if the element is visible,
unobscured by any other elements, and enabled - if the element is obscured, it will raise this exception.

### Likely Cause

**UI Elements Overlapping**

Elements on the UI are typically placed next to each other, but occasionally elements may overlap. For example,
a navbar always staying at the top of your window as you scroll a page. If that navbar happens to be covering
an element we are trying to click, Selenium might believe it to be visible and enabled, but when you try to click
it will throw this exception. Pop-ups and Modals are also common offenders here.

**Animations**

Elements with animations have the potential to cause this exception as well - it is recommended to wait for
animations to cease before attempting to click an element.

### Possible Solutions

**Use Explicit Waits**

[Explicit Waits]({{< ref "/documentation/webdriver/waits" >}}) will likely be your best friend in these instances.
A great way is to use `ExpectedCondition.ToBeClickable()` with `WebDriverWait` to wait until the right moment.

**Scroll the Element into View**

In instances where the element is out of view, but Selenium still registers the element as visible
(e.g. navbars overlapping a section at the top of your screen), you can use the `WebDriver.executeScript()`
method to execute a javascript function to scroll (e.g. `WebDriver.executeScript('window.scrollBy(0,-250)')`)
or you can utilize the Actions class with `Actions.moveToElement(element)`.

## Invalid SessionId Exception

Sometimes the session you're trying to access is different than what's currently available

### Likely Cause

This usually occurs when the session has been deleted (e.g. `driver.quit()`) or if the session has changed, like when the last tab/browser has closed (e.g. `driver.close()`)
This usually occurs when the session has been deleted (e.g. `driver.quit()`) or if the session has changed,
like when the last tab/browser has closed (e.g. `driver.close()`)

### Possible Solutions

Check your script for instances of `driver.close()` and `driver.quit()`, and any other possible causes of closed tabs/browsers. It could be that you are locating an element before you should/can.
Check your script for instances of `driver.close()` and `driver.quit()`, and any other possible causes
of closed tabs/browsers. It could be that you are locating an element before you should/can.
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ Elements do not get relocated automatically; the driver creates a reference ID f
has a particular place it expects to find it in the DOM. If it can not find the element
in the current DOM, any action using that element will result in this exception.

### Common Causes
### Likely Cause

This can happen when:

* You have refreshed the page, or the DOM of the page has dynamically changed.
* You have navigated to a different page.
* You have switched to another window or into or out of a frame or iframe.

### Common Solutions
### Possible Solutions

**The DOM has changed**

Expand Down Expand Up @@ -92,14 +92,52 @@ You can't just relocate it from the current context,
and you can't switch back to an active context where it is valid. If this is the reason
for your error, you must both navigate back to the correct location and relocate it.

## ElementClickInterceptedException

This exception occurs when Selenium tries to click an element, but the click would instead
be received by a different element. Before Selenium will click an element, it checks if the
element is visible, unobscured by any other elements, and enabled - if the element is obscured,
it will raise this exception.

### Likely Cause

**UI Elements Overlapping**

Elements on the UI are typically placed next to each other, but occasionally elements may overlap.
For example, a navbar always staying at the top of your window as you scroll a page. If that navbar
happens to be covering an element we are trying to click, Selenium might believe it to be visible
and enabled, but when you try to click it will throw this exception. Pop-ups and Modals are also
common offenders here.

**Animations**

Elements with animations have the potential to cause this exception as well - it is recommended to
wait for animations to cease before attempting to click an element.

### Possible Solutions

**Use Explicit Waits**

[Explicit Waits]({{< ref "/documentation/webdriver/waits" >}}) will likely be your best friend in these instances.
A great way is to use `ExpectedCondition.ToBeClickable()` with `WebDriverWait` to wait until the right moment.

**Scroll the Element into View**

In instances where the element is out of view, but Selenium still registers the element as visible
(e.g. navbars overlapping a section at the top of your screen), you can use the `WebDriver.executeScript()`
method to execute a javascript function to scroll (e.g. `WebDriver.executeScript('window.scrollBy(0,-250)')`)
or you can utilize the Actions class with `Actions.moveToElement(element)`.

## Invalid SessionId Exception

Sometimes the session you're trying to access is different than what's currently available

### Likely Cause

This usually occurs when the session has been deleted (e.g. `driver.quit()`) or if the session has changed, like when the last tab/browser has closed (e.g. `driver.close()`)
This usually occurs when the session has been deleted (e.g. `driver.quit()`) or if the session has changed,
like when the last tab/browser has closed (e.g. `driver.close()`)

### Possible Solutions

Check your script for instances of `driver.close()` and `driver.quit()`, and any other possible causes of closed tabs/browsers. It could be that you are locating an element before you should/can.
Check your script for instances of `driver.close()` and `driver.quit()`, and any other possible causes of closed
tabs/browsers. It could be that you are locating an element before you should/can.
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ Elements do not get relocated automatically; the driver creates a reference ID f
has a particular place it expects to find it in the DOM. If it can not find the element
in the current DOM, any action using that element will result in this exception.

### Common Causes
### Likely Cause

This can happen when:

* You have refreshed the page, or the DOM of the page has dynamically changed.
* You have navigated to a different page.
* You have switched to another window or into or out of a frame or iframe.

### Common Solutions
### Possible Solutions

**The DOM has changed**

Expand Down Expand Up @@ -92,6 +92,44 @@ You can't just relocate it from the current context,
and you can't switch back to an active context where it is valid. If this is the reason
for your error, you must both navigate back to the correct location and relocate it.

## ElementClickInterceptedException

This exception occurs when Selenium tries to click an element, but the click would instead
be received by a different element. Before Selenium will click an element, it checks if the
element is visible, unobscured by any other elements, and enabled - if the element is obscured,
it will raise this exception.

### Likely Cause

**UI Elements Overlapping**

Elements on the UI are typically placed next to each other, but occasionally elements may overlap.
For example, a navbar always staying at the top of your window as you scroll a page. If that navbar
happens to be covering an element we are trying to click, Selenium might believe it to be visible
and enabled, but when you try to click it will throw this exception. Pop-ups and Modals are also
common offenders here.

**Animations**

Elements with animations have the potential to cause this exception as well - it is recommended
to wait for animations to cease before attempting to click an element.

### Possible Solutions

**Use Explicit Waits**

[Explicit Waits]({{< ref "/documentation/webdriver/waits" >}}) will likely be your best friend in these instances.
A great way is to use `ExpectedCondition.ToBeClickable()` with `WebDriverWait`
to wait until the right moment.

**Scroll the Element into View**

In instances where the element is out of view, but Selenium still registers the element as visible
(e.g. navbars overlapping a section at the top of your screen), you can use the
`WebDriver.executeScript()` method to execute a javascript function to scroll
(e.g. `WebDriver.executeScript('window.scrollBy(0,-250)')`) or you can utilize the Actions
class with `Actions.moveToElement(element)`.

## Invalid SessionId Exception

Sometimes the session you're trying to access is different than what's currently available
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,44 @@ WebDriver并不会自动重新定位,
如果这是您的错误原因,
您必须回到正确的位置并重新定位元素。

## ElementClickInterceptedException

This exception occurs when Selenium tries to click an element, but the click would instead
be received by a different element. Before Selenium will click an element, it checks if the
element is visible, unobscured by any other elements, and enabled - if the element is obscured,
it will raise this exception.

### Likely Cause

**UI Elements Overlapping**

Elements on the UI are typically placed next to each other, but occasionally elements may overlap.
For example, a navbar always staying at the top of your window as you scroll a page. If that navbar
happens to be covering an element we are trying to click, Selenium might believe it to be visible
and enabled, but when you try to click it will throw this exception. Pop-ups and Modals are also
common offenders here.

**Animations**

Elements with animations have the potential to cause this exception as well - it is recommended
to wait for animations to cease before attempting to click an element.

### Possible Solutions

**Use Explicit Waits**

[Explicit Waits]({{< ref "/documentation/webdriver/waits" >}}) will likely be your best friend
in these instances. A great way is to use `ExpectedCondition.ToBeClickable()`
with `WebDriverWait` to wait until the right moment.

**Scroll the Element into View**

In instances where the element is out of view, but Selenium still registers the element as visible
(e.g. navbars overlapping a section at the top of your screen), you can use the
`WebDriver.executeScript()` method to execute a javascript function to scroll
(e.g. `WebDriver.executeScript('window.scrollBy(0,-250)')`) or you can utilize the
Actions class with `Actions.moveToElement(element)`.

## 无效 SessionId 异常
有时您尝试访问的会话与当前可用的会话不同。

Expand Down

0 comments on commit 799d3c4

Please sign in to comment.