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的所有类型,都启动安全模式

        

  • 相关阅读:
    功能小改进
    通过Performancing for Firefox发布Blog
    朋友当上了世界杯志愿者
    社区公告
    [新功能]通过作者名访问Blog
    用统一加速器解决网通用户访问博客园速度慢的问题
    通过备份数据库恢复SharePoint文档库中被删除的文件
    Web Application Projects的一个问题
    博客园将迈出重要的一步,注册一个公司
    Outlook 2003中的一些不足之处
  • 原文地址:https://www.cnblogs.com/zhuhaiying/p/4933720.html
Copyright © 2011-2022 走看看