Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/automate-skills-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Fails if automate/*/SKILL.md or automate/README.md no longer match automate/_source.
# Fix locally with: python3 automate/_source/build.py
name: Automate skills up to date

on:
pull_request:
branches: ["main"]
paths: ["automate/**", ".github/workflows/automate-skills-check.yml"]
push:
branches: ["main"]
paths: ["automate/**", ".github/workflows/automate-skills-check.yml"]

permissions:
contents: read

jobs:
check:
name: Generated skills match their source
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- run: python3 -I automate/_source/build.py --check
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ AI agent skills for BrowserStack products. Each skill teaches a coding agent (Cl
| Product | Folder |
| --- | --- |
| App Automate | [`app-automate/`](app-automate/) |
| Automate | [`automate/`](automate/) |

Each product folder has its own README listing its skills and the exact prompts to use.

Expand Down
117 changes: 117 additions & 0 deletions automate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Automate skills

Each skill takes a coding agent from one pasted prompt to a build on the BrowserStack Automate dashboard: BrowserStack's official sample build, or your own tests with no changes to your test logic. The agent checks your credentials, shows a plan, waits for your OK, runs the build and returns the dashboard link.

| Framework | Language | Runs on | Sample repo | Docs | Skill |
| --- | --- | --- | --- | --- | --- |
| Selenium | Java | real desktop browsers and real mobile devices | [`junit-browserstack@master`](https://github.com/browserstack/junit-browserstack/tree/master) | [getting started](https://www.browserstack.com/docs/automate/selenium/getting-started/java) | [`selenium-java`](selenium-java/SKILL.md) |
| Selenium | Python | real desktop browsers and real mobile devices | [`python-selenium-browserstack@main`](https://github.com/browserstack/python-selenium-browserstack/tree/main) | [getting started](https://www.browserstack.com/docs/automate/selenium/getting-started/python) | [`selenium-python`](selenium-python/SKILL.md) |
| Selenium | JavaScript | real desktop browsers and real mobile devices | [`jest-js-browserstack@main`](https://github.com/browserstack/jest-js-browserstack/tree/main) | [getting started](https://www.browserstack.com/docs/automate/selenium/getting-started/nodejs) | [`selenium-javascript`](selenium-javascript/SKILL.md) |
| Selenium | C# | real desktop browsers and real mobile devices | [`xunit-browserstack@main`](https://github.com/browserstack/xunit-browserstack/tree/main) | [getting started](https://www.browserstack.com/docs/automate/selenium/getting-started/c-sharp) | [`selenium-csharp`](selenium-csharp/SKILL.md) |
| Playwright | JavaScript | real desktop browsers, with real Android and iPhone on request | [`node-js-playwright-browserstack@main`](https://github.com/browserstack/node-js-playwright-browserstack/tree/main) | [getting started](https://www.browserstack.com/docs/automate/playwright/getting-started/nodejs) | [`playwright-javascript`](playwright-javascript/SKILL.md) |
| Playwright | Python | real desktop browsers, with a real iPhone on request | [`pytest-playwright-browserstack@main`](https://github.com/browserstack/pytest-playwright-browserstack/tree/main) | [getting started](https://www.browserstack.com/docs/automate/playwright/getting-started/python) | [`playwright-python`](playwright-python/SKILL.md) |
| Playwright | Java | real desktop browsers, with a real iPhone on request | [`java-playwright-browserstack@main`](https://github.com/browserstack/java-playwright-browserstack/tree/main) | [getting started](https://www.browserstack.com/docs/automate/playwright/getting-started/java) | [`playwright-java`](playwright-java/SKILL.md) |
| Playwright | C# | real desktop browsers, with a real iPhone on request | [`csharp-playwright-browserstack@main`](https://github.com/browserstack/csharp-playwright-browserstack/tree/main) | [getting started](https://www.browserstack.com/docs/automate/playwright/getting-started/c-sharp) | [`playwright-csharp`](playwright-csharp/SKILL.md) |

## Prompts

Set `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` as environment variables first; never paste the key into a prompt.

**Selenium Java**

Run the sample build:
```
Download https://raw.githubusercontent.com/browserstack/agent-skills/main/automate/selenium-java/SKILL.md and save it permanently in this project's skills folder as browserstack-automate-selenium-java/SKILL.md, then follow that skill to run the Selenium Java sample build on BrowserStack Automate.
```
Run your own tests:
```
Download https://raw.githubusercontent.com/browserstack/agent-skills/main/automate/selenium-java/SKILL.md and save it permanently in this project's skills folder as browserstack-automate-selenium-java/SKILL.md, then follow that skill to run my own Selenium Java tests on BrowserStack Automate.
```

**Selenium Python**

Run the sample build:
```
Download https://raw.githubusercontent.com/browserstack/agent-skills/main/automate/selenium-python/SKILL.md and save it permanently in this project's skills folder as browserstack-automate-selenium-python/SKILL.md, then follow that skill to run the Selenium Python sample build on BrowserStack Automate.
```
Run your own tests:
```
Download https://raw.githubusercontent.com/browserstack/agent-skills/main/automate/selenium-python/SKILL.md and save it permanently in this project's skills folder as browserstack-automate-selenium-python/SKILL.md, then follow that skill to run my own Selenium Python tests on BrowserStack Automate.
```

**Selenium JavaScript**

Run the sample build:
```
Download https://raw.githubusercontent.com/browserstack/agent-skills/main/automate/selenium-javascript/SKILL.md and save it permanently in this project's skills folder as browserstack-automate-selenium-javascript/SKILL.md, then follow that skill to run the Selenium JavaScript sample build on BrowserStack Automate.
```
Run your own tests:
```
Download https://raw.githubusercontent.com/browserstack/agent-skills/main/automate/selenium-javascript/SKILL.md and save it permanently in this project's skills folder as browserstack-automate-selenium-javascript/SKILL.md, then follow that skill to run my own Selenium JavaScript tests on BrowserStack Automate.
```

**Selenium C#**

Run the sample build:
```
Download https://raw.githubusercontent.com/browserstack/agent-skills/main/automate/selenium-csharp/SKILL.md and save it permanently in this project's skills folder as browserstack-automate-selenium-csharp/SKILL.md, then follow that skill to run the Selenium C# sample build on BrowserStack Automate.
```
Run your own tests:
```
Download https://raw.githubusercontent.com/browserstack/agent-skills/main/automate/selenium-csharp/SKILL.md and save it permanently in this project's skills folder as browserstack-automate-selenium-csharp/SKILL.md, then follow that skill to run my own Selenium C# tests on BrowserStack Automate.
```

**Playwright JavaScript**

Run the sample build:
```
Download https://raw.githubusercontent.com/browserstack/agent-skills/main/automate/playwright-javascript/SKILL.md and save it permanently in this project's skills folder as browserstack-automate-playwright-javascript/SKILL.md, then follow that skill to run the Playwright JavaScript sample build on BrowserStack Automate.
```
Run your own tests:
```
Download https://raw.githubusercontent.com/browserstack/agent-skills/main/automate/playwright-javascript/SKILL.md and save it permanently in this project's skills folder as browserstack-automate-playwright-javascript/SKILL.md, then follow that skill to run my own Playwright JavaScript tests on BrowserStack Automate.
```

**Playwright Python**

Run the sample build:
```
Download https://raw.githubusercontent.com/browserstack/agent-skills/main/automate/playwright-python/SKILL.md and save it permanently in this project's skills folder as browserstack-automate-playwright-python/SKILL.md, then follow that skill to run the Playwright Python sample build on BrowserStack Automate.
```
Run your own tests:
```
Download https://raw.githubusercontent.com/browserstack/agent-skills/main/automate/playwright-python/SKILL.md and save it permanently in this project's skills folder as browserstack-automate-playwright-python/SKILL.md, then follow that skill to run my own Playwright Python tests on BrowserStack Automate.
```

**Playwright Java**

Run the sample build:
```
Download https://raw.githubusercontent.com/browserstack/agent-skills/main/automate/playwright-java/SKILL.md and save it permanently in this project's skills folder as browserstack-automate-playwright-java/SKILL.md, then follow that skill to run the Playwright Java sample build on BrowserStack Automate.
```
Run your own tests:
```
Download https://raw.githubusercontent.com/browserstack/agent-skills/main/automate/playwright-java/SKILL.md and save it permanently in this project's skills folder as browserstack-automate-playwright-java/SKILL.md, then follow that skill to run my own Playwright Java tests on BrowserStack Automate.
```

**Playwright C#**

Run the sample build:
```
Download https://raw.githubusercontent.com/browserstack/agent-skills/main/automate/playwright-csharp/SKILL.md and save it permanently in this project's skills folder as browserstack-automate-playwright-csharp/SKILL.md, then follow that skill to run the Playwright C# sample build on BrowserStack Automate.
```
Run your own tests:
```
Download https://raw.githubusercontent.com/browserstack/agent-skills/main/automate/playwright-csharp/SKILL.md and save it permanently in this project's skills folder as browserstack-automate-playwright-csharp/SKILL.md, then follow that skill to run my own Playwright C# tests on BrowserStack Automate.
```

## Maintaining these skills

The `SKILL.md` files are generated. Edit `_source/` (`template.md` for everything the skills share, `parts/<skill>/` for language-specific sections, `skills.json` for names, sample repos and platforms), then run:

```bash
python3 automate/_source/build.py # regenerate the skills and this README
python3 automate/_source/build.py --check # fail if anything is out of date
```

Prompts point at `main`, so a merge is live for new installs: test both prompts from your branch's raw URL before merging.
116 changes: 116 additions & 0 deletions automate/_source/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/usr/bin/env python3
"""Generate every automate/<skill>/SKILL.md from one shared template.

Edit automate/_source/ (template.md, skills.json, parts/), never the generated SKILL.md files:
a fix made once in the template reaches every language.

python3 automate/_source/build.py # regenerate all skills
python3 automate/_source/build.py --check # exit 1 if any SKILL.md is out of date
"""
import json
import pathlib
import re
import sys

SRC = pathlib.Path(__file__).resolve().parent
AUTOMATE = SRC.parent
RAW = "https://raw.githubusercontent.com/browserstack/agent-skills/main/automate/{folder}/SKILL.md"


def prompt(skill, kind):
"""The exact prompt a docs page shows: kind is 'sample' or 'own'."""
what = (f"run the {skill['label']} sample build" if kind == "sample"
else f"run my own {skill['label']} tests")
return (f"Download {RAW.format(folder=skill['folder'])} and save it permanently in this "
f"project's skills folder as {skill['name']}/SKILL.md, then follow that skill to "
f"{what} on BrowserStack Automate.")


def prompts_table(skills, current):
"""The other skills: how to recognise their projects, and the own-tests prompt to hand over."""
lines = []
for s in skills:
if s["folder"] == current["folder"]:
continue
lines.append(f" - **{s['label']}** ({s['project_signal']}):\n"
f" `{prompt(s, 'own')}`")
return "\n".join(lines)


def render(text, skill, skills):
def part(m):
path = SRC / "parts" / skill["folder"] / f"{m.group(1)}.md"
return path.read_text().rstrip("\n")

text = re.sub(r"\{\{part:([a-z_]+)\}\}", part, text)
values = dict(skill)
values["raw_url"] = RAW.format(folder=skill["folder"])
values["sample_yml_raw"] = (f"https://raw.githubusercontent.com/browserstack/{skill['sample_repo']}/"
f"{skill['sample_branch']}{skill['sample_subdir']}/browserstack.yml")
values["prompt_sample"] = prompt(skill, "sample")
values["prompt_own"] = prompt(skill, "own")
values["prompts_table"] = prompts_table(skills, skill)
for key, val in values.items():
if isinstance(val, str):
text = text.replace("{{" + key + "}}", val)
left = re.findall(r"\{\{[^}]+\}\}", text)
if left:
sys.exit(f"{skill['folder']}: unresolved placeholders {sorted(set(left))}")
return text


def readme(skills):
"""automate/README.md: the skill table and the two prompts per skill, from the same source."""
out = ["# Automate skills", "",
"Each skill takes a coding agent from one pasted prompt to a build on the BrowserStack "
"Automate dashboard: BrowserStack's official sample build, or your own tests with no "
"changes to your test logic. The agent checks your credentials, shows a plan, waits for "
"your OK, runs the build and returns the dashboard link.", "",
"| Framework | Language | Runs on | Sample repo | Docs | Skill |",
"| --- | --- | --- | --- | --- | --- |"]
for s in skills:
out.append(f"| {s['framework']} | {s['language']} | {s['platform_kind']} | "
f"[`{s['sample_repo']}@{s['sample_branch']}`](https://github.com/browserstack/{s['sample_repo']}/tree/{s['sample_branch']}) | "
f"[getting started]({s['docs_url']}) | "
f"[`{s['folder']}`]({s['folder']}/SKILL.md) |")
out += ["", "## Prompts", "",
"Set `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` as environment variables first; "
"never paste the key into a prompt.", ""]
for s in skills:
out += [f"**{s['label']}**", "", "Run the sample build:", "```", prompt(s, "sample"), "```",
"Run your own tests:", "```", prompt(s, "own"), "```", ""]
out += ["## Maintaining these skills", "",
"The `SKILL.md` files are generated. Edit `_source/` (`template.md` for everything the "
"skills share, `parts/<skill>/` for language-specific sections, `skills.json` for names, "
"sample repos and platforms), then run:", "",
"```bash", "python3 automate/_source/build.py # regenerate the skills and this README",
"python3 automate/_source/build.py --check # fail if anything is out of date", "```", "",
"Prompts point at `main`, so a merge is live for new installs: test both prompts from "
"your branch's raw URL before merging.", ""]
return "\n".join(out)


def main():
check = "--check" in sys.argv
skills = json.loads((SRC / "skills.json").read_text())
template = (SRC / "template.md").read_text()
stale = []
outputs = [(AUTOMATE / s["folder"] / "SKILL.md", render(template, s, skills)) for s in skills]
outputs.append((AUTOMATE / "README.md", readme(skills)))
for out, text in outputs:
if check:
if not out.exists() or out.read_text() != text:
stale.append(str(out.relative_to(AUTOMATE.parent)))
else:
out.parent.mkdir(parents=True, exist_ok=True)
out.write_text(text)
print(f"wrote {out.relative_to(AUTOMATE.parent)} ({text.count(chr(10))} lines)")
if check:
if stale:
print("Out of date — run python3 automate/_source/build.py:\n " + "\n ".join(stale))
sys.exit(1)
print(f"All {len(skills)} skills and the README are up to date.")


if __name__ == "__main__":
main()
7 changes: 7 additions & 0 deletions automate/_source/parts/playwright-csharp/next_offers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- **Real iPhone:** add a real iPhone 15 (Safari) as its own build (B1 has the row and how). After
an iPhone-only run, offer the desktop build instead. Set expectations first:
Playwright on real iOS is a custom WebKit integration with limits (for example one browser
context per session, and some keyboard and multi-tab behaviour differs from desktop WebKit), so
a failure there doesn't change the desktop results. Real Android phones need BrowserStack's device API rather
than a normal browser launch, so this skill doesn't set them up: see https://www.browserstack.com/docs/automate/playwright/playwright-android/c-sharp.
- **Wider coverage:** add Edge, older browser versions or other operating systems.
29 changes: 29 additions & 0 deletions automate/_source/parts/playwright-csharp/own_assess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Note these in a short Assessment block at the top of your plan:

- **Project:** the test `.csproj` (and the solution, if any), its `TargetFramework(s)`, and the test
framework: NUnit, MSTest or xUnit.
- **Playwright version:** `Microsoft.Playwright` (and `Microsoft.Playwright.NUnit` or `.MSTest`);
keep the user's version.
- **How the browser is created:** a `PageTest`/`BrowserTest` base class, or
`Playwright.CreateAsync()` with `Chromium`/`Firefox`/`Webkit.LaunchAsync()`, is routed by the SDK
to the platforms in `browserstack.yml`; confirm on the API after the run. `ExecutablePath`,
`LaunchPersistentContextAsync` or `ConnectAsync` to another endpoint runs on the local machine.
- **Target framework runtime:** if the project targets a .NET version whose runtime isn't
installed, plan to run with `DOTNET_ROLL_FORWARD=Major` (no file change).
- **Real iPhone (on request, as its own build):** for that run, use only this platform in
`browserstack.yml` with a new `buildName` (check it against the live catalog as in step A3), and
put the desktop rows back afterwards if the user wants both:
```yaml
platforms:
- deviceName: iPhone 15
osVersion: 17
browserName: safari
```
The SDK opens one session per test, so `PageTest` and `LaunchAsync` tests stay within iOS's
one-context limit, and it names and marks each session.
- **Real Android:** needs BrowserStack's device API (`Android.ConnectAsync`), which is a code
change, so this skill doesn't set it up. Never add an Android row: device sessions still start
and stay `done` (see Troubleshooting). Point the user to https://www.browserstack.com/docs/automate/playwright/playwright-android/c-sharp.
- **Which tests to run:** the ones the user named (as a `dotnet test --filter`); otherwise all. If
they named a flow that has no test, pick the test whose name is the nearest step in that flow,
and if two are equally close, the first by file path. State the pick and why.
Loading
Loading