0

我尝试了很多选项,但总是有 /tmp/rust_mozprofileXYZ 配置文件

我将本地文件夹链接到 Firefox 容器并尝试选择它。

我也尝试在容器中创建配置文件并简单地选择它。

全部失败

这是日志

mozrunner::runner       INFO    Running command: "/usr/bin/firefox" "--marionette" "-foreground" 
"-no-remote" "-profile" "/tmp/rust_mozprofile8Q4N0k"

这是一些例子:

 $firefoxProfile = new FirefoxProfile('/home/seluser/.mozilla/firefox/t5umgtio.test2');
//        $firefoxProfile->setPreference("webdriver.firefox.profile",'/home/seluser/.mozilla/firefox/t5umgtio.test2');
        $firefoxProfile->setPreference("browser.download.downloadDir",'/home/seluser');
        $firefoxProfile->setPreference("webdriver.firefox.profile",'test2');
        $firefoxProfile->setPreference("-profile",'/home/seluser/.mozilla/firefox/t5umgtio.test2');
        $firefoxProfile->setPreference("-firefoxProfileTemplate",'/home/seluser/.mozilla/firefox/');
        $firefoxProfile->setPreference("-Dwebdriver.firefox.profile",'test2');

        $capabilities = DesiredCapabilities::firefox ();
//        $capabilities->setCapability(FirefoxDriver::PROFILE, $firefoxProfile);
//        $capabilities->setCapability('acceptSslCerts', false);
        $capabilities->setCapability('--marionette', false);
        $capabilities->setCapability("Dwebdriver.firefox.profile", 'test2');
        $capabilities->setCapability("-firefoxProfileTemplate", '/home/seluser/.mozilla/firefox/');
        $capabilities->setCapability("-profile", 'test2');
        $capabilities->setCapability("profile", 'test2');
        $capabilities->setCapability("firefoxProfileTemplate", 'test2');
//        $capabilities->setCapability('-profile', '/home/seluser/.mozilla/firefox/t5umgtio.test2');
//        $capabilities->setCapability('--profile', '/home/seluser/.mozilla/firefox/t5umgtio.test2');

        $web_driver = RemoteWebDriver::create(
            $host,
            $capabilities
        );

我使用 docker-compose

 firefox-hub:
      image: selenium/node-firefox-debug
      container_name: firefox-hub
      depends_on:
        - selenium-hub
      environment:
        - SCREEN_WIDTH=1024
        - SCREEN_HEIGHT=800
        - HUB_PORT_4444_TCP_ADDR=selenium-hub
        - HUB_PORT_4444_TCP_PORT=4444
        - NODE_MAX_SESSION=10
        - NODE_MAX_INSTANCES=10
        - SE_EVENT_BUS_HOST=selenium-hub
        - SE_EVENT_BUS_PUBLISH_PORT=4444
        - GRID_DEBUG=true
      volumes:
        - /dev/shm:/dev/shm
        - ./var/firefox-profiles:/home/seluser/.mozilla/firefox

我不知道这是正确的,但在日志中我看到类似的东西

"-firefoxProfileTemplate": "\u002fhome\u002fseluser\u002f.mozilla\u002ffirefox\u002f",

$host = 'selenium-hub:4444/wd/hub';
        $web_driver = RemoteWebDriver::create(
            $host,
            $capabilities
        );

我也尝试了chrome但没有成功

在 chrome in log 我看到

10:52:26.934 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"chromeOptions": {
"args": [
"user-data-dir=\u002fhome\u002fseluser\u002f.config\u002fgoogle-chrome\u002f",
"--user-data-dir=\u002fhome\u002fseluser\u002f.config\u002fgoogle-chrome\u002f",
"--profile-directory=grekClient",

也许 \u002f 是问题?我设置

$options->addArguments([
"user-data-dir=/home/seluser/.config/google-chrome/",
"--user-data-dir=/home/seluser/.config/google-chrome/",
4

0 回答 0