相关疑难解决方法(0)

unknown error: DevTools Active Port file doesn't exist java selenium

I am new to Selenium with Java. Followed online tutorial and tried executing the below code but am getting error message

unknown error: DevTools Active Port file doesn't exist java selenium.

I surfed on google and added the options arguments but nothing works.

package mainfiles;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class MainClass {

    static WebDriver driver;        

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        System.setProperty("webdriver.chrome.driver", "E:\\Selenium\\Latest jar files\\chromedriver.exe");
        ChromeOptions options = new ChromeOptions();
        //options.setExperimentalOption("useAutomationExtension", false); …
Run Code Online (Sandbox Code Playgroud)

java selenium-chromedriver selenium-webdriver

5
推荐指数
1
解决办法
2万
查看次数

如何使用 Java + ChromeDriver 在 AWS Lambda 中运行 Google Chrome 进行 Selenium 测试

我使用以下版本:

  • 硒 - 3.14.0
  • Webdrivermanager - 2.2.4

要创建 ChromeDriver,我使用以下配置:

WebDriverManager.chromedriver()
            .targetPath("/tmp")
            .setup();

    ChromeOptions options = new ChromeOptions();
    options.addArguments("--headless", "--no-sandbox", "--disable-dev-shm-usage");
    options.setBinary("/tmp");

    ChromeDriver driver = new ChromeDriver(options);
Run Code Online (Sandbox Code Playgroud)

当我运行我的 lambda 时,会发生以下异常(来自 lambda 日志):

org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /tmp is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Run Code Online (Sandbox Code Playgroud)

在 AWS Lambda 中安装 Chrome 浏览器并为 ChromeDriver 提供它有什么好方法吗?

java selenium headless selenium-chromedriver aws-lambda

5
推荐指数
1
解决办法
1249
查看次数

浏览器黄昏测试“DevToolsActivePort 文件不存在”

我正在为浏览器运行 Laravel Dusk 的示例测试,但是当我执行php artisan dusk时出现错误

使用: * Ubuntu 18 * Laravel 5.8 * Dusk 5.1 * ChromeDriver 74 * apache2

这是我的 DuskTestCase.php:

    <?php

    namespace Tests;

    use Laravel\Dusk\TestCase as BaseTestCase;
    use Facebook\WebDriver\Chrome\ChromeOptions;
    use Facebook\WebDriver\Remote\RemoteWebDriver;
    use Facebook\WebDriver\Remote\DesiredCapabilities;

    abstract class DuskTestCase extends BaseTestCase
    {
    use CreatesApplication;

/**
 * Prepare for Dusk test execution.
 *
 * @beforeClass
 * @return void
 */
public static function prepare()
{
    static::startChromeDriver();
}

/**
 * Create the RemoteWebDriver instance.
 *
 * @return \Facebook\WebDriver\Remote\RemoteWebDriver
 */
protected function …
Run Code Online (Sandbox Code Playgroud)

php testing laravel-dusk

5
推荐指数
2
解决办法
3870
查看次数

WebDriverException:Chrome无法启动:异常退出(未知错误:DevToolsActivePort文件不存在)

尽管版本正确并且安装了 UI,但使用 Selenium 的 Python 脚本无法创建 Chrome 实例。

我已经在这里查看了类似的线程,但似乎都没有解决问题。该代码在 Windows 上运行 - 一旦我尝试在 Linux 上执行它,它就不再运行。我的预期目标是让它以可视方式打开 Chrome,因此我并不是在寻找涉及虚拟显示的解决方案。

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--no-sandbox')

driver = webdriver.Chrome('/home/ethan/chromedriver', chrome_options=options)
driver.set_window_size(1024, 600)
driver.maximize_window()
Run Code Online (Sandbox Code Playgroud)

我安装了 Google Chrome 75.0.3770.100 我还安装了 ChromeDriver 75.0.3770.90

这是代码的完整回溯:

File "cm_update_01.py", line 114, in <module>
    if __name__ == "__main__": main()
  File "cm_update_01.py", line 24, in main
    with open(fetch_file()) as f:
  File "cm_update_01.py", line 75, in fetch_file
    driver = webdriver.Chrome('/home/ethan/chromedriver', chrome_options=options)
  File "/home/ethan/.local/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in …
Run Code Online (Sandbox Code Playgroud)

python selenium python-3.x selenium-chromedriver selenium-webdriver

5
推荐指数
1
解决办法
2万
查看次数

空白页面:Python 中的 Selenium Chrome 自动化

我正在尝试在 Python 中使用 selenium 和 chrome 浏览器自动化一个过程。我的浏览器对大多数页面都可以正常工作,但无法呈现一些页面,包括chrome://version/.

对于一般自动化(无头),它正确返回页面和页面源,而对于无头浏览,它返回一个空白页面,页面源如下

<html><head></head><body></body></html>
Run Code Online (Sandbox Code Playgroud)

我曾在不同的操作系统中尝试过 chrome,包括 OpenSUSE、fedora 和 Windows。我尝试了很多事情,例如:删除所有初始参数,使用无头浏览器。

供参考:如果我运行此代码

from selenium.webdriver import Chrome
from selenium.webdriver import ChromeOptions
options = ChromeOptions()
# to remove all arguments
options.add_experimental_option( 'excludeSwitches', ['disable-hang-monitor', 'disable-prompt-on-repost', 'disable-background-networking', 'disable-sync', 'disable-translate', 'disable-web-resources', 'disable-client-side-phishing-detection', 'disable-component-update', 'disable-default-apps', 'disable-zero-browsers-open-for-tests', '--enable-automation', '--use-mock-keychain', '--user-data-dir', '--enable-blink-features', '--disable-popup-blocking', '--enable-logging --force-fieldtrials=SiteIsolationExtensions/Control', '--enable-logging', '--force-fieldtrials', '--ignore-certificate-errors', '--load-extension', '--log-level', '--no-first-run','--password-store','--remote-debugging-port','--test-type'
]) 
options.add_argument("--headless")
options.add_argument("--no-sandbox")
browser = Chrome(executable_path=driver_path,options=options)
browser.get("chrome://version")
print(browser.page_source)
Run Code Online (Sandbox Code Playgroud)

它为无头返回相同的空白页

<html><head></head><body></body></html>
Run Code Online (Sandbox Code Playgroud)

如果 chrome 在没有无头选项的情况下运行,它将完全正常工作。

<!doctype html>
<!--
about:version template …
Run Code Online (Sandbox Code Playgroud)

javascript python selenium google-chrome selenium-webdriver

5
推荐指数
1
解决办法
1367
查看次数

从渲染器接收消息超时:10.000

运行我的场景时出现以下错误。

org.openqa.selenium.TimeoutException:超时:从渲染器接收消息超时:10.000

(会话信息:chrome=79.0.3945.79)构建信息:版本:'3.14.0',修订版:'aacccce0',时间:'2018-08-02T20:19:58.91Z'系统信息:主机:'fv-az598 ', ip: '10.1.0.4', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-1064-azure', java.version: '1.8.0_212' 驱动程序信息: org.openqa.selenium.remote.RemoteWebDriver 功能 {acceptInsecureCerts: false, browserName: chrome,browserVersion: 79.0.3945.79, chrome: { chromedriverVersion: 79.0.3945.36

正如您所看到的,使用粗体、突出显示的字体,我确实有 chrome 和 chrome 驱动程序的匹配版本。

我还向我的 ChromeOptions 传递了一些参数,这意味着超时方面的帮助:

        // options to prevent TIMEOUTS
        options.addArguments("start-maximized"); ///sf/answers/1839867291/
        options.addArguments("enable-automation"); ///sf/answers/3068808991/
        options.addArguments("--no-sandbox"); ///sf/answers/3550814291/
        options.addArguments("--disable-infobars"); ///sf/answers/3068808991/
        options.addArguments("--disable-dev-shm-usage"); ///sf/answers/3550814291/
        options.addArguments("--disable-browser-side-navigation"); ///sf/answers/3438620671/
        options.addArguments("--disable-gpu"); ///sf/ask/3637199051/
        options.addArguments("--disable-features=VizDisplayCompositor"); ///sf/ask/3876153781/
Run Code Online (Sandbox Code Playgroud)

编辑:在 DOCKER 容器中运行时会发生这种情况(使用 Chrome 浏览器的最新 docker 映像和 node-chrome-debug)

任何想法将不胜感激。

java selenium google-chrome selenium-chromedriver docker

5
推荐指数
1
解决办法
1万
查看次数

在 Selenium 中使用无头 Chrome 设置用户数据目录

我试图让无头 Chrome 工作,同时使用以下命令设置用户数据目录:

from selenium import webdriver

options = webdriver.ChromeOptions();
options.add_argument('--user-data-dir=./User_Data') 
options.add_argument('--headless')

browser = webdriver.Chrome(options=options)
Run Code Online (Sandbox Code Playgroud)

这将返回此错误消息:

selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist
Run Code Online (Sandbox Code Playgroud)

以下任何情况都不会阻止此消息的显示(如此处所建议的:WebDriverException:未知错误:DevToolsActivePort 文件在尝试启动 Chrome 浏览器时不存在

options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
options.add_argument("--disable-gpu")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--no-sandbox")
options.add_experimental_option("useAutomationExtension", False)
Run Code Online (Sandbox Code Playgroud)

我能找到的唯一可以防止出现此错误的方法是添加此参数:

options.add_argument('--remote-debugging-port=45447')
Run Code Online (Sandbox Code Playgroud)

这至少会启动一个无头 Chrome,但仍然不会获取指定的用户目录,在没有无头参数的情况下运行时,一切似乎都按预期工作。

如何让无头 Chrome 使用用户数据目录?

python selenium google-chrome google-chrome-headless

5
推荐指数
0
解决办法
7147
查看次数

如何在 Repl.it 上使用 selenium?

我正在尝试在 Repl 中使用 Selenium,但由于某种原因它似乎不起作用,有办法解决这个问题吗?

chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')

driver = webdriver.Chrome(options=chrome_options)

driver.get("https://www.youtube.com/watch?v=dQw4w9WgXcQ")

views = driver.find_element_by_class("view-count style-scope ytd-video-view-count-renderer")
print(views)
Run Code Online (Sandbox Code Playgroud)

这是我似乎遇到的两个错误。

Traceback (most recent call last):
  File "/home/runner/JustStuff/venv/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 71, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'
Run Code Online (Sandbox Code Playgroud)
Traceback (most recent call last):
  File "main.py", line 15, in <module>
    driver = webdriver.Chrome(options=chrome_options)
  File "/home/runner/JustStuff/venv/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", …
Run Code Online (Sandbox Code Playgroud)

python selenium-chromedriver selenium-webdriver replit

3
推荐指数
1
解决办法
3871
查看次数

org.openqa.selenium.WebDriverException:未知错误:DevToolsActivePort文件不存在

我尝试在作为节点连接到硒网格的远程PC上启动电子应用程序。以前它可以正常工作。但是现在我收到此错误“ DevToolActivePort文件不存在”

    System.out.println("launch application in windows PC");     
    capa  = new DesiredCapabilities();

    capa.setBrowserName("chrome");
    File file = new File("path\\to\\file\\.exe"); 
    URL server = new URL("http://ip_of_remote_pc:4444/wd/hub"); 

    ChromeOptions options = new ChromeOptions();
    options.setBinary(file);   //Sets the path to the Chrome executable
    capa.setCapability(ChromeOptions.CAPABILITY, options);
    driver2 = new RemoteWebDriver(server, capa); //launch the application
    System.out.println("launching application in remote PC");
    driver2.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);   
    System.out.println("Application launched"); 
Run Code Online (Sandbox Code Playgroud)

java selenium-chromedriver selenium-webdriver remotewebdriver

2
推荐指数
1
解决办法
3296
查看次数

同时运行多个 Selenium Chrome 配置文件

首先,这不是一个重复的问题!在标记为重复之前阅读并观看!我问这个问题是关于使用 selenium c# 打开多个 chrome 配置文件并导航 URL,正如您提到的,在这个线程中不重复 好吗?对你的预算感到羞耻,却没有任何帮助!

您对硒一无所知,我不希望您的答案超出我的问题,好吗?德班詹B


我想同时运行多个 Selenium Chrome Portable Profile。我想同时运行多个实例。

并使用

Navigate().GoToUrl("http://www.somesite.com");
Run Code Online (Sandbox Code Playgroud)

如果该程序只有一个实例正在运行,则一切都会正常。如果我在第一个实例运行时启动第二个实例,浏览器会打开,但自动化不会启动。

出现此错误:

ChromeDriver 驱动程序 = new ChromeDriver(服务, 选项); OpenQA.Selenium.WebDriverException: '未知错误: Chrome 无法启动: 正常退出 (未知错误: DevToolsActivePort 文件不存在) (从 chrome 位置 D:\GoogleChromePortable\GoogleChromePortable.exe 启动的进程不再运行,因此 ChromeDriver假设 Chrome 已经崩溃。)

一切都在这个视频中:https://www.uselooom.com/share/58725b7fdbb447df86b983107c3b35cf

如何打开多个 chrome 配置文件,并且每个配置文件都打开视频中所述的 URL!

我使用 C# 来实现 selenium,chr​​ome 是版本 68 chromedriver 2.41,!我正在使用自定义配置文件和 ChromePortable 二进制文件。

谢谢!

c#

2
推荐指数
1
解决办法
4608
查看次数

显示错误 - 未知错误:DevToolsActivePort 文件不存在 - 它是电子应用程序(我使用的是 Windows 操作系统))

当我运行代码时,它显示以下错误 - Electron application

org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist.
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'DESKTOP-GN8LLQU', ip: '192.168.1.20', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.2'
Driver info: driver.version: ChromeDriver
Run Code Online (Sandbox Code Playgroud)

我的代码:

ChromeOptions opt = new ChromeOptions();
// path of your Electron Application
opt.setBinary("D:\\FOS\\fiber-optic-system-electron\\release\\angular-electron 0.1.0.exe");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("chromeOptions", opt);
capabilities.setBrowserName("chrome");
System.setProperty("webdriver.chrome.driver", "E:\\chromedriver_win32 (6)\\chromedriver.exe");
WebDriver driver = new ChromeDriver(capabilities);
Run Code Online (Sandbox Code Playgroud)

selenium google-chrome selenium-chromedriver electron java-11

2
推荐指数
1
解决办法
2万
查看次数

Docker 容器中使用 Selenium 和 Java 的 Headless chrome

我正在尝试使用 Docker 文件在 Docker 容器中运行无头 Chrome 浏览器,但每当它尝试使用它执行自动化脚本时就会出现崩溃问题。

我尝试将 Chrome 驱动程序版本更改为 75 和 76,但 Chrome 浏览器版本出现问题。

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("--disable-dev-shm-usage");
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--disable-setuid-sandbox");
chromeOptions.addArguments("disable-infobars");
chromeOptions.addArguments("--disable-extensions");
Run Code Online (Sandbox Code Playgroud)

java selenium docker

2
推荐指数
1
解决办法
7264
查看次数

Chrome 驱动程序在 Laravel Dusk 中失败 - “无法打开流:HTTP 请求失败!404 未找到”

在最后一天左右,我开始看到我的 Laravel Dusk 测试在我的 CI/CD 环境中失败(GitHub Actions)。

突然,运行一直运行良好的命令:

php artisan dusk:chrome-driver `/opt/google/chrome/chrome --version | cut -d " " -f3 | cut -d "." -f1`
Run Code Online (Sandbox Code Playgroud)

..失败并出现错误:

file_get_contents(https://chromedriver.storage.googleapis.com/LATEST_RELEASE_116):无法打开流:HTTP请求失败!HTTP/1.1 404 未找到

尝试通过强制版本 114 来解决此问题:

php artisan install:chrome-driver 114
Run Code Online (Sandbox Code Playgroud)

...失败并出现错误:

Facebook\WebDriver\Exception\SessionNotCreatedException:会话未创建:此版本的 ChromeDriver 仅支持 Chrome 版本 114

我该如何解决这个问题并让我的测试再次开始通过?

php laravel selenium-webdriver laravel-dusk

2
推荐指数
1
解决办法
1015
查看次数