Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): add Android.{launchServer,connect} #18263

Merged
merged 6 commits into from
Oct 25, 2022

Conversation

mxschmitt
Copy link
Member

No description provided.

Copy link
Member

@pavelfeldman pavelfeldman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's figure out if shared android device is a thing.

packages/playwright-core/src/client/android.ts Outdated Show resolved Hide resolved
@mxschmitt mxschmitt marked this pull request as ready for review October 24, 2022 22:07
@mxschmitt mxschmitt force-pushed the feature/android-add-launchserver branch from c12d630 to e620389 Compare October 24, 2022 22:25
docs/src/api/class-android.md Outdated Show resolved Hide resolved
docs/src/api/class-android.md Outdated Show resolved Hide resolved
docs/src/api/class-android.md Outdated Show resolved Hide resolved
async launchServer(options: LaunchAndroidServerOptions = {}): Promise<BrowserServer> {
const playwright = createPlaywright('javascript');
// 1. Pre-connect to the device
let devices = await playwright.android.devices({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd avoid a long-living connection here and would create a device upon the connection. I.e. instead of preLaunchedAndroidDevice: device pass preLaunchedAndroidDevice: deviceFactory.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea but this makes it harder when a device gets disconnected during launchServer and connect(). With the current impl the ws server will shut down when the adb connection drops.

const data = await androidDevice.shell('cat /data/local/tmp/hello-world');
expect(data).toEqual(Buffer.from('hello world'));
} finally {
await androidDevice.shell('rm /data/local/tmp/hello-world');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work for the timed out test.

@mxschmitt mxschmitt merged commit 805312b into microsoft:main Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants