Skip to content

Instantly share code, notes, and snippets.

@omisolaidowu
Last active February 1, 2024 01:21
Show Gist options
  • Save omisolaidowu/506766ff5484d1bbb8fd8aaebb8d9dc3 to your computer and use it in GitHub Desktop.
Save omisolaidowu/506766ff5484d1bbb8fd8aaebb8d9dc3 to your computer and use it in GitHub Desktop.
Initial
// import the required libraries
const { Builder } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
// set the path to udetected_chromedriver executable file
const chromeDriverPath = 'C:/Users/dell/AppData/Roaming/undetected_chromedriver/undetected_chromedriver.exe';
// set the path to your actual Chrome browser executable file
const chromeExePath = 'C:/Program Files/Google/Chrome/Application/chrome.exe';
// specify custom user agent
const customUserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36';
// set Chrome options
const chromeOptions = new chrome.Options();
chromeOptions.setChromeBinaryPath(chromeExePath);
// add the custom user agent
chromeOptions.addArguments(`user-agent=${customUserAgent}`);
// run Chrome in headless mode
chromeOptions.addArguments('--headless');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment