Encountering an issue while attempting to access a specific website using Selenium WebDriver in JavaScript with the Chrome browser. In the provided code snippet, the browser driver is initialized; however, there seems to be a problem when utilizing setChromeOptions(options) as the site fails to open. Upon removal of this line, the website loads without any issues, indicating potential misconfiguration in the Chrome options. In addition, multiple browser profiles need to be opened sequentially using a for loop.
Snippet:
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 issue seems to revolve around the setChromeOptions(options) line. Disabling this command allows the website to load successfully. Is there an error in how I'm passing the Chrome options?
Your assistance would be greatly appreciated!
The current loop has been deactivated as I'm focusing on resolving the configuration settings first.
Error: SessionNotCreatedError: session not created: Chrome failed to start: exited normally. (session not created: DevToolsActivePort file doesn't exist) (The process started from chrome location C:\Program Files\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)