Selenium WebDriver RuntimeException:进程在10秒后拒绝死亡,并且无法执行任务:无法找到可执行文件:taskkill [英] Selenium WebDriver RuntimeException:Process refused to die after 10 seconds, and couldn't taskkill it: Unable to find executable for: taskkill

查看:925
本文介绍了Selenium WebDriver RuntimeException:进程在10秒后拒绝死亡,并且无法执行任务:无法找到可执行文件:taskkill的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  public class Second {
  private WebDriver driver;
  private boolean acceptNextAlert = true;
  private StringBuffer verificationErrors = new StringBuffer();

  @BeforeClass
  public void beforeClass() {
  driver = new FirefoxDriver();
  driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  driver.manage().window().maximize();
  }


 @Test
  public void testSecond() throws Exception {
  driver.get("url");
  System.out.println("test two");
  Thread.sleep(5000);

 }

 @AfterClass
 public void afterClass() throws Exception{
  driver.quit();
    String verificationErrorString = verificationErrors.toString();
    if (!"".equals(verificationErrorString)) {
      fail(verificationErrorString);
    }
 }
}

这是一个testNG测试案例在driver.quit()中抛出Runtime Exception。
测试成功通过但测试完成后浏览器未关闭

Stack Trace:

This is a testNG test case which throws Runtime Exception at driver.quit(). test is passed successfully but browser is not closed after test completes
Stack Trace:

 FAILED CONFIGURATION: @AfterTest afterClass
java.lang.RuntimeException: Process refused to die after 10 seconds, and couldn't taskkill it: Unable to find executable for: taskkill
at org.openqa.selenium.os.ProcessUtils.killWinProcess(ProcessUtils.java:142)
at org.openqa.selenium.os.ProcessUtils.killProcess(ProcessUtils.java:81)
at org.openqa.selenium.os.UnixProcess$SeleniumWatchDog.destroyHarder(UnixProcess.java:248)
at org.openqa.selenium.os.UnixProcess$SeleniumWatchDog.access$2(UnixProcess.java:245)
at org.openqa.selenium.os.UnixProcess.destroy(UnixProcess.java:124)
at org.openqa.selenium.os.CommandLine.destroy(CommandLine.java:153)
at org.openqa.selenium.firefox.FirefoxBinary.quit(FirefoxBinary.java:259)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.quit(NewProfileExtensionConnection.java:202)
at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.quit(FirefoxDriver.java:376)
at org.openqa.selenium.firefox.FirefoxDriver.stopClient(FirefoxDriver.java:322)
at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:477)
at testNGTestCase.Second.afterClass(Second.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.TestRunner.afterRun(TestRunner.java:1014)
at org.testng.TestRunner.run(TestRunner.java:621)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: java.lang.NullPointerException: Unable to find executable for: taskkill
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:250)
at org.openqa.selenium.os.UnixProcess.<init>(UnixProcess.java:62)
at org.openqa.selenium.os.CommandLine.<init>(CommandLine.java:38)
at org.openqa.selenium.os.WindowsUtils.killPID(WindowsUtils.java:172)
at org.openqa.selenium.os.ProcessUtils.killWinProcess(ProcessUtils.java:138)

我已经将TcpTimedWaitDelay设为30秒。

I have given TcpTimedWaitDelay as 30 seconds.

推荐答案

taskkill是一个标准的Windows实用程序。 Selenium无法找到它的事实意味着环境变量PATH不包含包含标准系统实用程序的目录。对于现代Windows版本,它是C:\ Windows \ system32。

taskkill is a standard Windows utility. The fact that Selenium cannot find it means that the environment variable PATH does not include the directory that contains standard system utilities. It is C:\Windows\system32 for modern Windows versions.

将此目录添加到PATH变量(按照此说明修改PATH变量: http://www.computerhope.com/issues/ch000549.htm )并重新启动运行Selenium脚本的控制台或IDE应用此环境变化。

Add this directory to the PATH variable (follow this instruction to modify the PATH variable: http://www.computerhope.com/issues/ch000549.htm) and restart the console or IDE where you run Selenium scripts to apply this environment change.

这篇关于Selenium WebDriver RuntimeException:进程在10秒后拒绝死亡,并且无法执行任务:无法找到可执行文件:taskkill的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆