【问题标题】:Cannot run specific Firefox profile in Selenium using Node.js无法使用 Node.js 在 Selenium 中运行特定的 Firefox 配置文件
【发布时间】:2023-03-21 23:28:01
【问题描述】:

我正在尝试使用 Node.js 在现有的 Firefox 配置文件中运行 Selenium。但是,Node 一直说找不到配置文件。我正在运行 Arch Linux 和 Firefox 87。我的代码:

const webdriver = require("selenium-webdriver");
const firefox = require("selenium-webdriver/firefox");
const geckodriver = require("geckodriver"); //Did this instead of adding geckodriver to Path
const firefoxOptions = new firefox.Options();
const firefoxProfile = '/home/user_name/.mozilla/firefox/l6mcped3.selenium-test/';
firefoxOptions.setProfile(firefoxProfile);
let driver = new webdriver.Builder()
    .forBrowser("firefox")
    .setFirefoxOptions(firefoxOptions)
    .build();

结果(在 Firefox 配置文件关闭的情况下运行):

Running...
node:internal/process/promises:245
          triggerUncaughtException(err, true /* fromPromise */);
          ^

[Error: ENOENT: no such file or directory, stat '/home/user_name/.mozilla/firefox/l6mcped3.selenium-test/lock'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'stat',
  path: '/home/user_name/.mozilla/firefox/l6mcped3.selenium-test/lock'

但是,ls 显示文件存在。用户权限应该不是问题,但无论如何我尝试以sudo 运行并得到相同的结果。请帮忙。谢谢。

【问题讨论】:

    标签: javascript node.js selenium selenium-firefoxdriver


    【解决方案1】:

    尝试删除符号链接。这对我有用。 ?‍♂️

    【讨论】:

      猜你喜欢
      • 2011-11-28
      • 1970-01-01
      • 1970-01-01
      • 2015-08-06
      • 2016-06-25
      • 1970-01-01
      • 2019-11-21
      • 1970-01-01
      • 2016-09-11
      相关资源
      最近更新 更多