c165f2f788
Agrega 19 issues técnicas documentando funcionalidades implementadas y pendientes. Issues completadas (movidas a dev/issues/completed/): - 001-conversor-web-markdown.md - 002-accessibility-tree.md - 003-gestion-cookies-perfil.md - 004-gestion-extensiones-chrome.md - 005-eliminar-timeouts-innecesarios.md Issues implementadas: - 006-manejo-tabs-ventanas.md - 016-manejo-iframes.md - 017-actions-api.md - 018-file-uploads.md - 019-expected-conditions-mejoradas.md Issues pendientes (media prioridad): - 007-alert-prompt-confirm-handling.md - 008-screenshot-elementos-especificos.md - 009-pdf-generation.md - 010-device-emulation-completo.md - 011-downloads-handling.md Issues pendientes (baja prioridad / avanzado): - 012-browser-contexts-multi-sesion.md - 013-video-recording.md - 014-network-mocking-avanzado.md - 015-geolocation-permissions.md Incluye también dev/NUEVAS_FUNCIONALIDADES.md con resumen completo. Directorio: dev/
102 lines
2.6 KiB
Markdown
102 lines
2.6 KiB
Markdown
# Issue #010: Device Emulation Completo
|
|
|
|
**Tipo**: Enhancement
|
|
**Prioridad**: Media
|
|
**Estado**: Pendiente
|
|
|
|
## Descripción
|
|
|
|
Implementar emulación completa de dispositivos móviles y tablets (viewport, user-agent, touch, geolocation).
|
|
|
|
## Funcionalidad deseada
|
|
|
|
- Emular dispositivos predefinidos (iPhone, iPad, Android, etc.)
|
|
- Viewport personalizado (width, height, deviceScaleFactor)
|
|
- User-Agent específico de dispositivo
|
|
- Touch events habilitados
|
|
- Orientación (portrait/landscape)
|
|
- Geolocation personalizada
|
|
- Timezone específica
|
|
- Locale/idioma
|
|
- Permisos de dispositivo
|
|
|
|
## API propuesta
|
|
|
|
```go
|
|
type DeviceDescriptor struct {
|
|
Name string
|
|
UserAgent string
|
|
Viewport Viewport
|
|
DeviceScaleFactor float64
|
|
IsMobile bool
|
|
HasTouch bool
|
|
DefaultOrientation string
|
|
}
|
|
|
|
type Viewport struct {
|
|
Width int
|
|
Height int
|
|
}
|
|
|
|
type EmulationOptions struct {
|
|
Device *DeviceDescriptor
|
|
Viewport *Viewport
|
|
UserAgent string
|
|
IsMobile bool
|
|
HasTouch bool
|
|
Orientation string // "portrait" | "landscape"
|
|
Geolocation *Geolocation
|
|
Timezone string
|
|
Locale string
|
|
}
|
|
|
|
// Dispositivos predefinidos
|
|
var Devices = map[string]*DeviceDescriptor{
|
|
"iPhone 13": {...},
|
|
"iPhone 13 Pro": {...},
|
|
"iPad Pro": {...},
|
|
"Pixel 5": {...},
|
|
"Galaxy S21": {...},
|
|
}
|
|
|
|
func (b *Browser) Emulate(ctx context.Context, opts *EmulationOptions) error
|
|
func (b *Browser) EmulateDevice(ctx context.Context, deviceName string) error
|
|
func (b *Browser) SetViewport(ctx context.Context, width, height int) error
|
|
func (b *Browser) SetUserAgent(ctx context.Context, userAgent string) error
|
|
func (b *Browser) SetTouchEnabled(ctx context.Context, enabled bool) error
|
|
func (b *Browser) SetOrientation(ctx context.Context, orientation string) error
|
|
```
|
|
|
|
## Uso
|
|
|
|
```go
|
|
// Emular iPhone 13
|
|
b.EmulateDevice(ctx, "iPhone 13")
|
|
|
|
// Emulación personalizada
|
|
opts := &browser.EmulationOptions{
|
|
Viewport: &browser.Viewport{Width: 375, Height: 812},
|
|
UserAgent: "Mozilla/5.0 (iPhone...)",
|
|
IsMobile: true,
|
|
HasTouch: true,
|
|
Orientation: "portrait",
|
|
}
|
|
b.Emulate(ctx, opts)
|
|
```
|
|
|
|
## CDP Methods
|
|
|
|
- `Emulation.setDeviceMetricsOverride`
|
|
- `Emulation.setUserAgentOverride`
|
|
- `Emulation.setTouchEmulationEnabled`
|
|
- `Emulation.setEmulatedMedia`
|
|
- `Emulation.setGeolocationOverride`
|
|
- `Emulation.setTimezoneOverride`
|
|
- `Emulation.setLocaleOverride`
|
|
|
|
## Referencias
|
|
|
|
- CDP Emulation: https://chromedevtools.github.io/devtools-protocol/tot/Emulation/
|
|
- Playwright devices: https://playwright.dev/docs/emulation
|
|
- Puppeteer emulation: https://pptr.dev/guides/emulation
|