# wgc-client

WGC Client package for the QA framework. Provides `WGCClient` — the main class for interacting with Wargaming Game Center through WebSocket, JavaScript injection, and Win32 API.

## Architecture

```
WGCClient
├── Process Management (Win32 API)
│   ├── start_wgc() / stop_wgc()
│   ├── Process monitoring (crash detection)
│   └── Window handle management
│
├── WebSocket Communication
│   ├── /websocket/wgc          — main UI channel
│   ├── /websocket/overlay      — overlay channel
│   ├── /websocket/game-overlay — in-game overlay
│   └── /websocket/news         — news feed
│
├── UI Elements
│   ├── WebElement  — CSS selectors via JS injection
│   └── NativeElement — Win32 Accessibility API
│
└── UI Maps (34 .ini files)
    ├── common.ini, arsenalcommon.ini
    ├── arsenallogin.ini, arsenalshop.ini
    └── ... (page-specific element maps)
```

## Usage

```python
from wgc_client import WGCClient

# Initialize and start WGC
client = WGCClient()
client.run_game_center()

# Get UI elements
login_btn = client.get_wgc_element('button_login')
login_btn.click()

# Web elements (CSS selectors via WebSocket)
email_field = client.get_wgc_element('input_email')
email_field.set_text('user@test.com')
email_field.react_set_text('user@test.com')  # React-specific

# Native elements (Win32 API)
dialog = client.get_native_element('install_dialog')
dialog.click()

# Element properties
text = login_btn.get_text()
visible = login_btn.is_element_displayed
attrs = login_btn.get_attribute('class')
```

## UI Element Types

### WebElement
Interacts with Chromium UI via JavaScript injection over WebSocket:
- `click()`, `react_click()` — click via JS dispatchEvent
- `set_text()`, `react_set_text()` — input via nativeInputValueSetter
- `get_text()` — read innerText
- `get_attribute()` — read DOM attributes
- `is_element_displayed` — visibility check via offsetParent

### NativeElement
Interacts with native Windows UI via Win32 Accessibility API:
- `click()` — mouse_event at element coordinates
- `get_text()` — read acc_value via UISoup
- `set_text()` — set_value via UISoup
- For native dialogs, file pickers, OS-level windows

## UI Maps

Element selectors are defined in `.ini` files:
```ini
[common]
button_login = .login-button
input_email = input[name="email"]
game_list = .game-list-container
```

Parsed by `UIMapParser` and accessed via `client.get_wgc_element('button_login')`.

## Install

```bash
pip install wgc-client
```

## Dependencies

- `wgc-core`, `wgc-helpers`, `wgc-mocks`, `wgc-clippy`
- `websocket-client` — WebSocket communication
- `pywin32` — Win32 API
- `uisoup`, `uiautomation` — Windows UI automation
- `ui-map-parser` — INI-based UI map parsing
