简体   繁体   English

RSelenium rsDriver 给出错误无法杀死已退出的进程

[英]RSelenium rsDriver gives error can't kill an exited process

I am struggling to make RSelenium work on a unix server.我正在努力使 RSelenium 在 unix 服务器上工作。 It has Mozilla Firefox 60.6.1, and running the two commands:它有 Mozilla Firefox 60.6.1,并运行两个命令:

binman::list_versions("geckodriver")
$linux64
[1] "0.22.0" "0.23.0" "0.24.0"

binman::list_versions("seleniumserver")
$generic
[1] "3.141.59"      "4.0.0-alpha-1" "4.0.0-alpha-2"

it seems that the geckodriver is available (is it ?).似乎 geckodriver 可用(是吗?)。 But when I try to launch a driver :但是当我尝试启动驱动程序时:

> library(RSelenium)
> rD <- rsDriver(browser = "firefox",
+          extraCapabilities = list(
+            "moz:firefoxOptions" = list(
+              binary = "/usr/lib64/firefox/firefox",
+              args = list('--headless')
+            )
+          ))
...
[1] "Connecting to remote server"

Selenium message:invalid argument: can't kill an exited process
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'login2.cluster', ip: '192.168.100.12', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-957.5.1.el7.x86_64', java.version: '1.8.0_181'
Driver info: driver.version: unknown
remote stacktrace:

Could not open firefox browser.
Client error message:
         Summary: UnknownError
         Detail: An unknown server-side error occurred while processing the command.
         Further Details: run errorDetails method
Check server log for further details.

From this question and others I tried to downgrade the version of geckodriver, and make use of the headless mode of firefox:这个问题和其他问题我试图降级 geckodriver 的版本,并利用 firefox 的无头模式:

 rD <- rsDriver(browser = "firefox",
                version = "3.141.59",
                geckover = "0.22.0",
          extraCapabilities = list(
            "moz:firefoxOptions" = list(
              binary = "/usr/lib64/firefox/firefox",
              args = list('--headless')
            )
          ))

But still get the same error.但仍然得到同样的错误。 My suspicion would be that geckodriver is actually not installed.我怀疑实际上没有安装 geckodriver。 Is this possible ?这可能吗 ? How to check it ?如何检查?

Thank you for your help感谢您的帮助

You need to stick to your exact requirements regarding Selenium , GeckoDriver and Firefox versions which would be used in your test framework and remove the unwanted versions of binaries totally.您需要遵守有关SeleniumGeckoDriverFirefox版本的确切要求,这些版本将在您的测试框架中使用,并完全删除不需要的二进制文件版本。 GeckoDriver v0.24.0 being the latest release must be the chosen one.必须选择最新版本的GeckoDriver v0.24.0

Selenium v4.0.0-alpha-1 and Selenium v4.0.0-alpha-2 are alpha releases and must be avoided for Production usage. Selenium v​​4.0.0-alpha-1Selenium v​​4.0.0-alpha-2alpha版本,必须避免用于生产用途。 So Selenium v3.141.59 being the latest release must be the chosen one.因此,必须选择最新版本的Selenium v​​3.141.59

For GeckoDriver , Selenium and Firefox Browser compatibility you can find a detailed discussion in Which Firefox browser versions supported for given Geckodriver version?对于GeckoDriverSeleniumFirefox 浏览器兼容性,您可以在给定 Geckodriver 版本支持哪些 Firefox 浏览器版本中找到详细讨论

Note : You don't need to install the GeckoDriver binary but put the binary in the desired location.注意:您不需要安装GeckoDriver二进制文件,而是将二进制文件放在所需的位置。

So an ideal usage would be:所以理想的用法是:

rD <- rsDriver(browser = "firefox",
        version = "3.141.59",
        geckover = "0.24.0",
      extraCapabilities = list(
        "moz:firefoxOptions" = list(
          binary = "/usr/lib64/firefox/firefox",
          args = list('--headless')
        )
      ))

If you are still facing the issue follow the below mentioned steps.如果您仍然遇到问题,请按照以下步骤操作。


This error message...这个错误信息...

message:invalid argument: can't kill an exited process

...can surface for different reasons. ...可能出于不同的原因浮出水面。 The possible solution can be any/either of the following:可能的解决方案可以是以下任何一项/一项:

  • Ensure that GeckoDriver v0.24.0 is downloaded and placed within the directory that is already in your path, eg /usr/local/bin确保GeckoDriver v0.24.0已下载并放置在您路径中已有的目录中,例如/usr/local/bin
  • Ensure that GeckoDriver is having executable permission for non-root users.确保GeckoDriver非 root用户具有可执行权限。
  • Ensure that firefox (> v57.0) is installed (mandatory) within /usr/lib64/firefox/ directory as per your code block and the version is compatable.确保根据您的代码块在/usr/lib64/firefox/目录中安装(强制) firefox (> v57.0)并且版本兼容。
  • Ensure that if you are running Firefox on a system with no display you have to use headless mode .确保如果您在没有显示器的系统上运行Firefox ,您必须使用无头模式
  • The correct usage of headless mode with GeckoDriver v0.24.0 is: GeckoDriver v0.24.0无头模式的正确用法是:

     options.headless = True
  • There is no need for xvfb-run anymore if you set MOZ_HEADLESS=1 as follows:如果您将MOZ_HEADLESS=1设置为如下,则不再需要xvfb-run

     $ export MOZ_HEADLESS=1 # this way you only have to set it once
  • If you have changed your system path, take a System Reboot .如果您更改了系统路径,请执行System Reboot

  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.始终在tearDown(){}方法中调用driver.quit()以优雅地关闭和销毁WebDriverWeb Client实例。
  • Always execute your @Tests as a non-root user.始终以非 root用户身份执行@Tests

References参考

You can find a relevant detailed discussions in:您可以在以下位置找到相关的详细讨论:

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

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