You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website_and_docs/content/documentation/webdriver/troubleshooting/errors/_index.zh-cn.md
+19-5Lines changed: 19 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -101,27 +101,41 @@ WebDriver并不会自动重新定位,
101
101
102
102
## ElementClickInterceptedException
103
103
104
-
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.
104
+
This exception occurs when Selenium tries to click an element, but the click would instead
105
+
be received by a different element. Before Selenium will click an element, it checks if the
106
+
element is visible, unobscured by any other elements, and enabled - if the element is obscured,
107
+
it will raise this exception.
105
108
106
109
### Likely Cause
107
110
108
111
**UI Elements Overlapping**
109
112
110
-
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.
113
+
Elements on the UI are typically placed next to each other, but occasionally elements may overlap.
114
+
For example, a navbar always staying at the top of your window as you scroll a page. If that navbar
115
+
happens to be covering an element we are trying to click, Selenium might believe it to be visible
116
+
and enabled, but when you try to click it will throw this exception. Pop-ups and Modals are also
117
+
common offenders here.
111
118
112
119
**Animations**
113
120
114
-
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.
121
+
Elements with animations have the potential to cause this exception as well - it is recommended
122
+
to wait for animations to cease before attempting to click an element.
115
123
116
124
### Possible Solutions
117
125
118
126
**Use Explicit Waits**
119
127
120
-
Explicit 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.
128
+
[Explicit Waits]({{< ref "/documentation/webdriver/waits" >}}) will likely be your best friend
129
+
in these instances. A great way is to use `ExpectedCondition.ToBeClickable()`
130
+
with `WebDriverWait` to wait until the right moment.
121
131
122
132
**Scroll the Element into View**
123
133
124
-
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)`.
134
+
In instances where the element is out of view, but Selenium still registers the element as visible
135
+
(e.g. navbars overlapping a section at the top of your screen), you can use the
136
+
`WebDriver.executeScript()` method to execute a javascript function to scroll
137
+
(e.g. `WebDriver.executeScript('window.scrollBy(0,-250)')`) or you can utilize the
138
+
Actions class with `Actions.moveToElement(element)`.
0 commit comments