java selenium离开僵尸进程
我正在设置一个测试套件来测试一些内部的(最终是外部的[production]来替换pingdom),但现在当我在eclipse中运行它时,“run as Java Application”的每一次调用都会挂起,留下一些僵尸进程,什么也不输出(我想挂起部分很明显)。但如果我杀死它(仍在Eclipse中),然后重新启动,它会立即输出页面,不会留下僵尸进程。因此,为了形象化,它是这样工作的:
- 在java应用程序运行时运行,并打印出我期望的内容
- java应用程序挂起时运行,几乎什么都不做(除了生成僵尸进程)
- 在java应用程序运行时运行,并打印出我期望的内容
- java应用程序挂起时运行,几乎什么都不做(除了生成僵尸进程)
- 李>
Jerry$ ps -ef | grep -i headless | wc
16 511 15011
Jerry$ ps -ef | grep -i headless | wc
21 678 19990
Jerry$ ps -ef | grep -i headless | wc
21 678 19990
Jerry$ ps -ef | grep -i headless | wc
26 845 24977
我试过几次,所以你可以看到它从16开始,经过几次跑步,现在是26僵尸(孤儿?)进程仍在后台运行
现在,代码:
public class SeleniumTest {
public static void main(String[] args) {
// Globally set the driver location
System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver");
// Locally pass in the options
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("--no-sandbox");
// Create the driver, download, and test
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get("http://192.168.2.15:8080/testApp/m/getBeans2");
System.out.println(driver.getPageSource());
System.out.println(driver.getCurrentUrl());
// This block was introduced around the 21 mark as I was testing if I had to
// quit first between subsequent calls, so calling it twice didn't lead to the
// initial 16 zombie processes, just the call to the QA server above
System.out.println("-------------------- LOCALHOST --------------------");
driver.get("http://localhost:8080/testApp/m/getBeans2");
System.out.println(driver.getPageSource());
System.out.println(driver.getCurrentUrl());
driver.quit();
}
}
现在我使用的是开放JDK 11、Chrome驱动程序95.0.4638.69和selenium的这个版本:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.1.0</version>
</dependency>
所以。。。为什么我会遇到僵尸/孤立进程——这是我在运行之间需要清理的东西吗
共 (0) 个答案