AI_UIAutomation/drivers/factory.ts

18 lines
645 B
TypeScript

import { DeviceDriver, Platform } from './types';
import { WDADriver } from './wda-driver';
import { AndroidDriver } from './android-driver';
import { APP_CONFIG } from '../config/app.config';
export function createDriver(platform?: Platform): DeviceDriver {
const targetPlatform = platform || APP_CONFIG.device.platform;
switch (targetPlatform) {
case 'ios':
return new WDADriver(APP_CONFIG.ios.wdaHost, APP_CONFIG.ios.wdaPort);
case 'android':
return new AndroidDriver(APP_CONFIG.android.appiumHost, APP_CONFIG.android.appiumPort);
default:
throw new Error(`Unsupported platform: ${targetPlatform}`);
}
}