WebDriver(Selenium2) 常见异常及处理方法

上一篇 / 下一篇  2014-06-17 10:26:14 / 个人分类:Selenium

Exception NoSuchElementException
ue&k/nN _+{0Solutions
"` Cj w4fo,^h5{z01. Check the locator of your target element.51Testing软件测试网"t3V`-O^ b3pp;F&z``
2. If the locator is current. Try to wait for page load before find element.51Testing软件测试网gYnv/W N BX3@
3. If already wait for long time and always cannot find the element, try to use another type locator.51Testing软件测试网gm7HKJP b

Y"j.s_ ^2K:U8xv @s Wq0Exception NoSuchWindowException51Testing软件测试网%L fslJ%f4L-Wt2A
Solutions
6KVj e p,D9c!E01.Check the window’s locator.
N'B-Q7uL]1I t!]02.Wait page load before find the window.
~ IzL"F0
7J{3J7_ R0Exception NoAlertPresentException51Testing软件测试网o:`%c1B,iMM%N ]
Solutions
b8W|)C4l6N3W.L uE9@01.Make sure the alert( javascript. pop window not new window) will present.51Testing软件测试网 [w.e"w$`m
2.Wait page load before deal the alert.
;h D/S } ]$~2N0
|&?-wd Kg,H/lh0Exception NoSuchFrameException
'G`Y i4O"G0Solutions51Testing软件测试网 Tl'Z&@5m
1.Check the frame’s locator.
3bA#@;f&~RB-Q:E8o02.Check is the frame. has some father frame.(if has father frame. you should switch to the father frame. first)
(I\6x&_3d*_ I03.Make sure switch to the default content before switch to target frame( only for single frame)
)J3t a$k!_y04.Wait page load before switch to frame.51Testing软件测试网F r2xMmj Kt j4^
51Testing软件测试网.yw1`;n Ci s+U
Exception UnhandledAlertException
8o3b"A|n3_8L(]oj0Solutions51Testing软件测试网.C$z,W;Yl
1. Check if there is some alert dialog present. ( JavaScript. pop window). And deal with them.51Testing软件测试网&x/B+c2G,r+r
2. If no javascript. pop window present but the exception still occurs. Make sure the developer tools is closed when running automation case. (Because since selenium 2.19. “UnhandledAlertException” added and they think the developer tool is an alert)
yF6]1_'k"Gd051Testing软件测试网9pW;OXyxZF J
Exception UnexpectedTagNameException
m/B7J6h:N(S|+TJY\+hF0Solutions
qF,oSz3Q!DOX Q;v01.Check the target element’s html tag name.
1Q g#B2a*O02.Try to wait for page load then initializing the selector.
4k/T3W;h%KL4|ZW6az:[*G051Testing软件测试网`5J Qwri1V;@0Gyt
Exception StaleElementReferenceException51Testing软件测试网$dg9qu'V7d*R
Solutions
S4}6b-b$w,zo01.Re-find the element again. (Because the element has been refresh.)51Testing软件测试网2sL6?#T y-|T [;t'G(u

s8zVH IQ3Yfy0Exception TimeoutException51Testing软件测试网7|!O k"Ph
Solutions
a C:NmJ{01. Check the expected conditions locator.
EX N5{:].H02..Increase the wait time.

TAG:

引用 删除 gaopei8013   /   2016-02-23 10:19:24
5
 

评分:0

我来说两句

Open Toolbar