WebDriver异常

本文列举了使用WebDriver进行自动化测试时可能遇到的各种异常情况及其解决方案,包括元素未找到、窗口异常、警告对话框处理不当等问题,并提供了针对性的检查和应对措施。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 
NoSuchElementException  
Solutions:
​    1. Check the locator of your target element.
​    2. If the locator is current. Try to wait for page load before find element.
    3. If already wait for long time and always cannot find the element, try to use another type locator.
 
NoSuchWindowException 
Solutions:
    1.Check the window’s locator. 
    2.Wait page load before find the window.
 
NoAlertPresentException
​Solutions:
    1.Make sure the alert( will present.
​    2.Wait page load before deal the alert.Exception
 
NoSuchFrameException
Solutions:
     1.Check the frame’s locator. 
    2.Check is the frame. has some father frame.(if has father frame. you should switch to the father frame. first)
     3.Make sure switch to the default content before switch to target frame( only for single frame)
    4.Wait page load before switch to frame.
 
UnhandledAlertException 
Solutions:
    1. Check if there is some alert dialog present. ( . And deal with them.
    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)
 
UnexpectedTagNameException
Solutions:
​    1.Check the target element’s html tag name.
    2.Try to wait for page load then initializing the selector.
 
StaleElementReferenceException
Solutions:
​    1.Re-find the element again. (Because the element has been refresh.)
 
TimeoutException
​Solutions:
    1. Check the expected conditions locator.
    2.Increase the wait time.

转载于:https://www.cnblogs.com/vanya/p/6742572.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值