Metadata-Version: 2.3
Name: automata-core
Version: 0.2.1
Summary: Add your description here
Author: Jia Hao
Author-email: Jia Hao <yeojiahao89@gmail.com>
Requires-Dist: pyyaml==6.0.3
Requires-Dist: replion>=0.1.0
Requires-Dist: selenium==4.51.0
Requires-Python: >=3.14
Description-Content-Type: text/markdown

# Automata Core

Automata Core runs browser actions, assertions, and waits through Selenium. The browser integration suite uses NORTHLINE, a six-page outdoor storefront fixture, to exercise those handlers against realistic navigation and interaction flows.

## Public API

Import `Automata` from the root of the installed library:

```python
from automata.core import Automata

result = Automata.run("suite.yml")  # Chrome by default
print(result.success)
```

Each case runs in a fresh browser session, which Automata closes after execution,
including failed cases. Loading and parsing errors raise before a browser starts.
Execution failures are returned in `result`; output is silent unless an adapter is supplied.

Choose Chrome, Edge, or Firefox, with optional headless mode:

```python
result = Automata.run("suite.yml", browser="firefox", headless=True)
result = Automata.run("suite.yml", browser="edge")
```

Pass Selenium options for further browser configuration:

```python
from selenium import webdriver
from automata.core import Automata
from automata.core.runtime.adapters import ConsoleAdapter

options = webdriver.ChromeOptions()
options.add_argument("--window-size=1440,900")
result = Automata.run(
    "suite.yml", browser="chrome", headless=True, options=options, adapter=ConsoleAdapter()
)
```

For Selenium Remote, a custom service, or another browser, pass a factory that
creates a new WebDriver on each call:

```python
result = Automata.run("suite.yml", create_driver=webdriver.Firefox)
```

Use either a custom factory or `browser`/`headless`/`options`. For manual browser work,
`Automata.create_driver()` forwards keyword arguments to Selenium. You own that
browser and must close it:

```python
driver = Automata.create_driver("chrome", headless=True, options=options)
try:
    driver.get("https://example.com")
finally:
    driver.quit()
```

The same helper supports `Automata.create_driver("firefox", headless=True)` and
`Automata.create_driver("edge", headless=True)`. Headless mode preserves supplied
options and adds its browser-specific argument to a separate copy.

## Output adapters

Execution is silent by default and always returns the same result objects.
Choose a built-in adapter when running a suite:

```python
from automata.core import Automata
from automata.core.runtime.adapters import ConsoleAdapter, JsonAdapter, XmlAdapter

result = Automata.run("suite.yml", create_driver=create_driver, adapter=ConsoleAdapter())
# Alternatively: adapter=JsonAdapter("results.json")
# Alternatively: adapter=XmlAdapter("results.xml")
```

Console output is plain text, with case statuses, errors, and a final summary.
JSON and XML adapters overwrite their destination at suite completion, including
case and executed-step results. Parent directories must already exist. JSON uses
the result field names; XML uses Automata's suite/case/step format, not JUnit.
File errors propagate to the caller. Direct Runner.run_test calls only emit case
callbacks; file adapters write reports when Runner.run_suite, Core.run, or Automata.run completes.
Extend `automata.core.runtime.adapter.Adapter` to provide custom CLI formatting.

## Explore the test site

From the repository root, start a local server:

```powershell
.venv\Scripts\python.exe -m http.server 8000 --directory tests/fixtures
```

Open `http://127.0.0.1:8000/index.html`. The site contains Home, Shop, Trail field kit, Your kit, Route desk, and Journal pages. Shop quick view and the product detail page both add to the same browser-local kit; the Route desk contains the profile form, interaction controls, 3D compass, and gear planner; Journal contains the field film.

## Run browser integration tests

```powershell
.venv\Scripts\python.exe -m unittest tests.test_integration -v
```

The suite starts its own HTTP server on a free localhost port and opens Chrome. It checks cross-page navigation and cart persistence in addition to the individual action, assertion, and wait handlers. The fixture pages and shared CSS/JavaScript live in `tests/fixtures/`.
