简体   繁体   English

Selenium Webdriver中的测试用例西装执行错误

[英]Test Case Suit Execution Error in selenium Webdriver

I have a test suite for 28 test cases(methods) in a single class. 我在一个类中有一个针对28个测试用例(方法)的测试套件。 Whenever i'm trying to run these methods/ execute test case unexpected no of test cases are getting failed some times error comes in Sleep command some times something else. 每当我尝试运行这些方法/执行测试用例时,意外的测试用例都不会失败,有时在Sleep命令中还会出现错误。 Error is not constant for any run. 错误对于任何运行都不是恒定的。

     @Test (priority = 5)
  public void AddModule() throws Exception {

     Workbook wb = Workbook.getWorkbook(srcCNRegression);
     driver.get(baseUrl1);
     Thread.sleep(5000);
     ModuleLink = driver.findElement(By.linkText("MODULES & INTERVENTIONS"));
     Thread.sleep(5000);
     //HighlightElement.elementHighlight(ModuleLink);
     ModuleLink.click();
     System.out.println(" Module link is open");
     Thread.sleep(5000);
     driver.findElement(By.linkText("Add Modules")).click();
     Thread.sleep(3000);
     // Click on the modules
     driver.findElement(By.name("page:frm:j_id204:1:j_id206")).click();
     Thread.sleep(3000);
     driver.findElement(By.name("page:frm:j_id214")).click(); 
     Thread.sleep(3000);
     System.out.println("Module is added" );

  }

With having a errors occurred , corresponding code (alone with the web site url you testing if possible) it is hard give a specific answer . 如果发生错误,则相应的代码(如果可能,请与您测试的网站URL一起单独存在)很难给出具体答案。 But I can give some suggestions 但我可以提出一些建议

01) Remove Thread.Sleep() , implement wait for specific element 01)删除Thread.Sleep(),实现等待特定元素

02) Comment out all the test and add one-by-one to isolate specific place you are getting the error . 02)注释掉所有测试,并一一添加以隔离出现错误的特定位置。 One reason for similar situation is Application not the state that particular test is expecting , so even if you see multiple tests getting fail , the actual reason for failing could be in single test 发生类似情况的原因之一是应用程序不是特定测试所期望的状态 ,因此即使您看到多个测试失败,实际的失败原因也可能是在单个测试中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM