From ad18256217f6a9d842b9e2c32e8f983bcaf772aa Mon Sep 17 00:00:00 2001 From: Ken Yasue Date: Sun, 23 Mar 2025 22:37:07 +0100 Subject: [PATCH] trying to use edge --- src/index.ts | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 94307fc..f97c07f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,16 +12,36 @@ import { getCities } from './lib/cities'; import { WebDriverUtils, saveContactInfoToCSV } from './lib/utils'; import * as UIActions from './lib/UIActions'; import { randomUUID } from 'crypto'; - +import os from 'os'; +import edge from 'selenium-webdriver/edge'; /** * Function to visit TripAdvisor pages for each city */ async function visitCityPages(): Promise { - const cities = getCities(path.join(__dirname, '../data/cities.csv')); + const userHomeDir = os.homedir(); // gets C:\Users\ + const driverPath = path.join(userHomeDir, 'Documents', 'edgedriver_win64', 'msedgedriver.exe'); + + // Configure Edge service to use your custom driver path + const service = new edge.ServiceBuilder(driverPath); + + const options = new edge.Options(); + options.addArguments('--inprivate'); + options.addArguments('--start-maximized'); + + let driver: WebDriver; + driver = await new Builder() + .forBrowser('MicrosoftEdge') + .setEdgeOptions(options) + .setEdgeService(service) + .build(); + + await driver.get('https://www.tripadvisor.com'); + await WebDriverUtils.wait(5); + + /* - console.log('Connecting to existing Chrome browser...'); // Connect to an existing Chrome browser running in debug mode on port 9222 const options = new chrome.Options(); @@ -34,6 +54,11 @@ async function visitCityPages(): Promise { .forBrowser('chrome') .setChromeOptions(options) .build(); + */ + + const cities = getCities(path.join(__dirname, '../data/cities.csv')); + + console.log('Connecting to existing Chrome browser...'); // Visit each city's TripAdvisor page for (let i = 0; i < cities.length; i++) {