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

[Feature] Implement launchServer and connect for Android #17538

Closed
pranavj1001 opened this issue Sep 22, 2022 · 1 comment
Closed

[Feature] Implement launchServer and connect for Android #17538

pranavj1001 opened this issue Sep 22, 2022 · 1 comment
Assignees

Comments

@pranavj1001
Copy link
Contributor

Playwright Android currently lacks the connect and launchServer methods that enable the client-server architecture for the Playwright Desktop sessions.

This will enable users to launch a server on a remote machine that has mobile devices connected to it and the users will be able to connect to this from another machine.

We have raised a POC PR for this with a working code to enable the methods mentioned above. The methods are similar to the methods being used for Playwright Desktop. However, there are still a few differences.

  /**
   * This methods attaches Playwright to an existing android instance.
   * @param wsEndpoint A browser websocket endpoint to connect to.
   * @param options
   */
  connect(wsEndpoint: string, options?: {
    headers?: { [key: string]: string; };
    logger?: Logger;
    slowMo?: number;
    timeout?: number;
  }): Promise<AndroidDevice>;

The connect method requires mainly a web socket endpoint (which can be retrieved by launching the server) and returns an instance of AndroidDevice through which the users can execute commands and run their scripts.

/**
   * Returns the browser app instance.
   *
   * Launches browser server that client can connect to.
   * @param options
   */
  launchServer(options?: {
    args?: Array<string>;
    channel?: string;
    chromiumSandbox?: boolean;
    deviceSerialNumber?: string; // new option
    devtools?: boolean;
    downloadsPath?: string;
    env?: { [key: string]: string|number|boolean; };
    executablePath?: string;
    handleSIGHUP?: boolean;
    handleSIGINT?: boolean;
    handleSIGTERM?: boolean;
    headless?: boolean;
    ignoreDefaultArgs?: boolean|Array<string>;
    logger?: Logger;
    port?: number;
    proxy?: {
      server: string;
      bypass?: string;
      username?: string;
      password?: string;
    };
    timeout?: number;
    tracesDir?: string;
    wsPath?: string;
  }): Promise<BrowserServer>;

The launchServer method initializes a server that communicates with the client and delegates the instructions to the connected AndroidDevice. The users can get the web socket endpoint of the server after launching it and calling wsEndpoint() on the server instance. We have also added an option of deviceSerialNumber which tries to connect with the device whose serial number is provided.

Note:

  • Detailed explanation of each param can be found here on the PR.
  • The code in the PR is not complete yet. Unit tests are still pending and also some changes might be required once it gets reviewed from your side.
  • The PR has been tested locally and is working fine.

We are happy to collaborate on this with your team and eager to listen to your thoughts on this.

@ovidb
Copy link

ovidb commented Oct 29, 2022

I see this has been closed as completed, does this mean it was accepted?

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

No branches or pull requests

5 participants