I’m facing an issue when trying to open a specific site using Selenium WebDriver in JavaScript with the Chrome browser. The code below creates the browser driver, but it doesn’t open the site when I use setChromeOptions(options). If I remove this line, the site opens normally. It seems there is something wrong with the Chrome options configuration. Additionally, I’m using a for loop because I need the driver to open all 4 browser profiles.
code:
const { Builder, Browser, By } = require("selenium-webdriver");
const chrome = require('selenium-webdriver/chrome');
const DEFAULT_DIR = "user-data-dir=C:\Users\allan\AppData\Local\Google\Chrome\User Data";
const PROFILES = ["profile-directory=Profile 3", "profile-directory=Profile 4", "profile-directory=Profile 5", "profile-directory=Profile 7"];
//GOMES = Profile 3 / MODAS = Profile 4 / ROCCO = Profile 5 / STORE = Profile 7
async function run(){
//for (let i = 0; i < PROFILES.length; i++){
var options = new chrome.Options();
options.addArguments("user-data-dir=C:\Users\allan\AppData\Local\Google\Chrome\User Data");
options.addArguments(PROFILES[1]);
let navegador = await new Builder()
.forBrowser(Browser.CHROME)
//.setChromeOptions(options)
.build();
await navegador.get("https://sellercentral.amazon.com.br/home");
//}
}
run();
The problematic line seems to be setChromeOptions(options). If I comment out this line, the browser opens the site correctly. Is there something wrong with the Chrome options I’m passing?
Any help is appreciated!
The loop is currently disabled as I am trying to resolve the configuration settings first.
Allan Aristides is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.