如何使用 NodeJS 和 Selenium 以私有模式启动 Firefox?
How to launch Firefox in Private Mode with NodeJS and Selenium?
我正在尝试使用 TypeScript 在私有模式下启动 Firefox。我已经试过了,它不会使用私人模式:
static async CreateFirefoxDriver():Promise<WebDriver>
{
//Create the firefox capabilities
var firefoxCapabilities = Capabilities.firefox();
//Use Private Window
var firefoxOptions = {
'args': ['-private']};
firefoxCapabilities.set('firefoxOptions', firefoxOptions);
var driver = await new Builder().withCapabilities(firefoxCapabilities).build();
//Maximize the window
await driver.manage().window().maximize();
return driver;
}
正确配置方法如下:
static async CreateFirefoxDriver():Promise<WebDriver>
{
var options = new firefox.Options();
options.addArguments("-private");
var driver = await new Builder().forBrowser("firefox").setFirefoxOptions(options).build();
//Maximize the window
await driver.manage().window().maximize();
return driver;
}
我正在尝试使用 TypeScript 在私有模式下启动 Firefox。我已经试过了,它不会使用私人模式:
static async CreateFirefoxDriver():Promise<WebDriver>
{
//Create the firefox capabilities
var firefoxCapabilities = Capabilities.firefox();
//Use Private Window
var firefoxOptions = {
'args': ['-private']};
firefoxCapabilities.set('firefoxOptions', firefoxOptions);
var driver = await new Builder().withCapabilities(firefoxCapabilities).build();
//Maximize the window
await driver.manage().window().maximize();
return driver;
}
正确配置方法如下:
static async CreateFirefoxDriver():Promise<WebDriver>
{
var options = new firefox.Options();
options.addArguments("-private");
var driver = await new Builder().forBrowser("firefox").setFirefoxOptions(options).build();
//Maximize the window
await driver.manage().window().maximize();
return driver;
}