2017-08-30 38 views
1

我是新来硒和自动化测试,我面临着以下错误信息:超时无效指定类型:网页加载

org.openqa.selenium.InvalidArgumentException: Invalid timeout type specified: page load 

当运行测试/登录/用户和传球是有类型极其缓慢 - 每10-15秒钟一个符号。我能够登录,但测试失败,提到的错误信息。 我该如何解决它,让测试运行得更快一点,我认为是问题所在?

的Windows 10 IE 11 即驾驶员32位3.5.0

,代码:

@Before 
public void setUp() throws Exception { 

    System.setProperty("webdriver.ie.driver", "D:\\Documents\\SeleniumDriver\\IEDriverServer.exe"); 

    this.driver = new InternetExplorerDriver(); 
    this.driver.manage().window().maximize(); 
    driver.manage().timeouts().implicitlyWait(4000, TimeUnit.MINUTES); 
    driver.get(Constant.URL); 

    ExcelUtils.setExcelFile(Constant.Path_TestData + Constant.File_TestData, "Sheet1"); 

} 

@SuppressWarnings("deprecation") 
@Test 
public void Activation() throws Exception { 

    LoginModel.LoginAdminCredentials(driver); 

    driver.manage().timeouts().pageLoadTimeout(4000, TimeUnit.MINUTES); 

    String currentURL = driver.getCurrentUrl(); 

    Assert.assertEquals("expectedURL", currentURL); 

} 
+1

可能摆脱driver.manage的'( ).timeouts()。pageLoadTimeout(4000,TimeUnit.MINUTES);'在测试 – nullpointer

+0

感谢它的工作原理和错误不可见。即使那个测试仍然运行得太慢。任何想法如何解决速度问题? – evitta15

回答

0

你应该在你@Test方法摆脱

driver.manage().timeouts().pageLoadTimeout(4000, TimeUnit.MINUTES); 

,因为driver.manage().timeouts()值的生命直到驱动程序的实例处于活动状态,无论是默认值还是自定义值se t由用户。


此外,以减少你的执行的时间,你可以尝试用替换

driver.manage().timeouts().implicitlyWait(4000, TimeUnit.MINUTES); 

更新@Before方法

driver.manage().timeouts().implicitlyWait(4000, TimeUnit.SECONDS); 
+0

完成!但是再次测试需要109,322秒。有没有办法运行它10秒? – evitta15

+0

@ evitta15你确定没有其他与上述相关的代码可能需要时间。像驱动程序初始化,设置功能等? – nullpointer

+0

是的,我的错只指向测试。有班级阅读用户,并通过excel +常数数据: – evitta15