【问题标题】:[Odoo][Odoov13] Run method with selenium[Odoo][Odoov13] 使用 selenium 运行方法
【发布时间】:2020-02-20 13:34:18
【问题描述】:

我有通过单击 Odoo 中的按钮运行的 python 脚本(使用 selenium)。 此脚本通过 chromedriver 使用 GUI 运行 chrome。 当它尝试运行时出现错误:

从 chrome 位置 /usr/bin/google-chrome 开始的进程是 no 运行时间更长,因此 ChromeDriver 假设 Chrome 已崩溃

一切都安装在我的虚拟机上,安装了 Ubuntu 18.04,安装在带有 Hyper-V 的计算机上(在 Windows 上) 我知道显示此错误是因为脚本无权访问 X 服务器。 所以我将用户添加到 X: xhost +SI:localuser:odoo_user

但我仍然有同样的问题:(

【问题讨论】:

    标签: linux virtual-machine odoo xorg odoo-13


    【解决方案1】:

    问题解决:

    1. pip install PyVirtualDisplay

    2. 下载并安装(您不需要相同的版本): https://ubuntu.pkgs.org/18.04/ubuntu-updates-main-amd64/xserver-common_1.19.6-1ubuntu4.4_all.deb.html dpkg -i xserver-common_1.19.6-1ubuntu4.4_all.deb

    3. apt install xfvb

    4. 您始终需要在系统中拥有相同版本的 chromedrive 和 chrome 浏览器。

    之后 chromedriver 可以在没有 GUI 的情况下运行 X 会话。

    【讨论】:

      【解决方案2】:

      是的,当我在 Odoo 中使用 selenium 时,我遇到了同样的问题,检查您的 chrome 版本并为您的 chrome 下载支持的 chrome 驱动程序并将其移动到您的“usr/bin”,授予该位置的完全权限并尝试下面的代码。

      from selenium import webdriver
      from selenium.webdriver.chrome.options import Options
           
      def test(self):
          driver = webdriver.Chrome()
          driver.get("www.google.com")
      

      【讨论】:

      • 我也有同样的问题。我有匹配的版本。甚至独立的 python 脚本运行良好,但是当在 Odoo 框架(表单视图按钮)中实现时,它给了我错误。 [ERROR] SessionNotCreatedException: Message: session not created from tab crashed
      【解决方案3】:

      这个问题的解决方法是安装 Selenium Grid 和 PyVirtualDisplay(你可以使用 docker)并尝试使用 Remote 选项:

      webdriver.Remote(URL_SERVER_SELENIUM, options);

      它对我有用。

      最好的问候。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-05-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-11-20
        • 2011-01-28
        • 2020-10-07
        • 1970-01-01
        相关资源
        最近更新 更多