获取由 Selenium 启动的浏览器的 PID(在 Java 中) [英] Get PID of browser started by Selenium (in java)

查看:73
本文介绍了获取由 Selenium 启动的浏览器的 PID(在 Java 中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以获取Selenium Webdriver启动的浏览器的PID.

Is it possible to get the PID of the browser that is started by Selenium Webdriver.

这必须是 Java 语言,因为这就是我运行 webdriver 的方式.这可能吗?

This would have to be in Java, as that is how I run webdriver. Is that possible?

推荐答案

不是特别的,您将获得当前正在运行的进程列表并对其进行过滤.

Not particularly, you would have get the list of processes currently running and filter it down.

Selenium 没有用于启动浏览器的特殊属性或功能.因此,如果您正在运行手动启动的该浏览器的实例,您也会得到它.也就是说,如果您有两个 Firefox 实例,一个是 Selenium 启动并正在对其进行测试,另一个是您自己的 Firefox 会话,那么您将两者都在过滤列表中,根本无法将它们区分开来.

There is no special attributes or features that Selenium uses to launch a browser. Therefore, if you are running an instance of that browser that was launched manually, you will get that too. That is to say that if you have two instances of Firefox, one that Selenium launched and is doing it's testing on, and one of your own Firefox sessions, then you are going to have both in the filtered list, there is no way at all to tell them apart.

看看这个所以问题.使用此代码获取所有当前正在运行的进程.将其过滤到您尝试使用的浏览器.

Take a look at this SO question. Use this code to get all currently running processes. Filter it down to the browser you are trying to get.

如果您解释这样做的目的,我们可能会给出更好的答案.

If you explain what you are trying to achieve by doing this, we may be able to give a better answer.

这篇关于获取由 Selenium 启动的浏览器的 PID(在 Java 中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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