wip
This commit is contained in:
@@ -162,26 +162,41 @@ export class PlaywrightBrowserSession {
|
||||
const persistentContext = this.persistentContext!;
|
||||
this.page = persistentContext.pages()[0] || await persistentContext.newPage();
|
||||
this.page.setDefaultTimeout(this.config.timeout ?? 10000);
|
||||
this.connected = true;
|
||||
return { success: true };
|
||||
this.connected = !!this.page;
|
||||
} else {
|
||||
this.browser = await launcher.launch({
|
||||
headless: effectiveMode === 'headless',
|
||||
args: [
|
||||
'--disable-blink-features=AutomationControlled',
|
||||
'--disable-features=IsolateOrigins,site-per-process',
|
||||
],
|
||||
ignoreDefaultArgs: ['--enable-automation'],
|
||||
});
|
||||
const browser = this.browser!;
|
||||
this.context = await browser.newContext();
|
||||
this.page = await this.context.newPage();
|
||||
this.page.setDefaultTimeout(this.config.timeout ?? 10000);
|
||||
this.connected = !!this.page;
|
||||
}
|
||||
|
||||
if (!this.page) {
|
||||
this.log('error', 'Browser session connected without a usable page', {
|
||||
hasBrowser: !!this.browser,
|
||||
hasContext: !!this.context || !!this.persistentContext,
|
||||
});
|
||||
await this.closeBrowserContext();
|
||||
this.connected = false;
|
||||
return { success: false, error: 'Browser not connected' };
|
||||
}
|
||||
|
||||
this.browser = await launcher.launch({
|
||||
headless: effectiveMode === 'headless',
|
||||
args: [
|
||||
'--disable-blink-features=AutomationControlled',
|
||||
'--disable-features=IsolateOrigins,site-per-process',
|
||||
],
|
||||
ignoreDefaultArgs: ['--enable-automation'],
|
||||
});
|
||||
const browser = this.browser!;
|
||||
this.context = await browser.newContext();
|
||||
this.page = await this.context.newPage();
|
||||
this.page.setDefaultTimeout(this.config.timeout ?? 10000);
|
||||
this.connected = true;
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
this.connected = false;
|
||||
this.page = null;
|
||||
this.context = null;
|
||||
this.persistentContext = null;
|
||||
this.browser = null;
|
||||
return { success: false, error: message };
|
||||
} finally {
|
||||
this.isConnecting = false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createImageTemplate, DEFAULT_CONFIDENCE, type CategorizedTemplate } from 'packages/domain/value-objects/ImageTemplate';
|
||||
import type { ImageTemplate } from 'packages/domain/value-objects/ImageTemplate';
|
||||
import { createImageTemplate, DEFAULT_CONFIDENCE, type CategorizedTemplate } from '@/packages/domain/value-objects/ImageTemplate';
|
||||
import type { ImageTemplate } from '@/packages/domain/value-objects/ImageTemplate';
|
||||
|
||||
/**
|
||||
* Template definitions for iRacing UI elements.
|
||||
|
||||
Reference in New Issue
Block a user