zoukankan      html  css  js  c++  java
  • webDriver运行过程中遇到的问题

    1.org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms.

     【原因】:     selenium的版本和firefox的版本不兼容

     【解决方法】:

           更新selenium和firfox配对的版本

    【Selenium】   -> 【FireFox】
    2.25.0        ->  18
    2.30.0        ->  19
    2.31.0        ->  20
    2.42.2        ->  29
    2.44.0        ->  33 (不支持31,2014/12/1)

    2. 【代码片段】:

                System.setProperty("webdriver.chrome.driver","E:\driver\chromedriver.exe");
    		ChromeDriver driver = new ChromeDriver();
    		
    		driver.get("http://localhost:8080/test/login.jsp");
    		driver.findElementByName("userName").sendKeys("test");
    		driver.findElementById("userPwd").sendKeys("test");
    		driver.findElementById("login").click();
    
    		System.out.println(driver.findElementByXPath("//*[@id='modify_psw']/a").getText());
    		
    		driver.close();
    

       【报错】:Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element

       【原因】:这个登录是用ajax完成的,而ajax不会引起整个页面刷新,对webdriver来说,他无法判断登录请求发起后是什么时候完成的。导致你的点击登录按钮之后,webdriver直接去页面找用户中心的链接了,而这个时候登录请求才发出去,还没有收到相应呢,也就是还处于未登录状态的页面,当然找不到你要的链接。所以你必须自己手动在点击登录按钮后,做一个等待,否则永远是失败的。

       【解决方法】: 加入Thread.sleep(5000);等待页面加载就好

    3.【代码片段】:

    	//打开IE8
    		System.setProperty("webdriver.ie.driver","E:\driver\IEDriverServer.exe");
    		InternetExplorerDriver driver = new InternetExplorerDriver();
    

    【报错】:Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)

    【原因】:IE浏览器的设置的安全模式不统一

    【解决方法】:将IE的所有类型,都启动安全模式

        

  • 相关阅读:
    对于工程师责任和责任边界的认知
    windows消息机制与实例
    final阶段团队贡献分分配
    Final阶段用户调查报告
    对金州勇士团队的项目进行功能分解(加分作业)
    final review 报告
    final发布评论
    本周PSP
    final发布视频
    【转】mac版微信web开发者工具(小程序开发工具)无法显示二维码 解决方案
  • 原文地址:https://www.cnblogs.com/zhuhaiying/p/4933720.html
Copyright © 2011-2022 走看看