Skip to content

Commit 466cd88

Browse files
authored
Update _index.zh-cn.md
1 parent ff6eda3 commit 466cd88

File tree

1 file changed

+19
-5
lines changed
  • website_and_docs/content/documentation/webdriver/troubleshooting/errors

1 file changed

+19
-5
lines changed

website_and_docs/content/documentation/webdriver/troubleshooting/errors/_index.zh-cn.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,27 +101,41 @@ WebDriver并不会自动重新定位,
101101

102102
## ElementClickInterceptedException
103103

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.
105108

106109
### Likely Cause
107110

108111
**UI Elements Overlapping**
109112

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.
111118

112119
**Animations**
113120

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.
115123

116124
### Possible Solutions
117125

118126
**Use Explicit Waits**
119127

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.
121131

122132
**Scroll the Element into View**
123133

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)`.
125139

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

0 commit comments

Comments
 (0)