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

Automatically generate Go interfaces code, etc. #367

Merged
merged 8 commits into from
Aug 24, 2023

Conversation

canstand
Copy link
Collaborator

Due to the rewrite of the go code generation scripts, it brings the following breaking changes:

  • Optimized generated comments. Links and Deprecated tags in Go doc comments now work.
    • May cause many Deprecated lint errors, please update the call or use //nolint:staticcheck to ignore.
  • Added event interface methods. For example Page.OnDialog() etc.
  • The signatures of some interface methods have changed, for example:
    • Unified optional parameter naming. For example, previously all Click used PageClickOptions, now
      Locator.Click(options ...LocatorClickOptions)
      Page.Click(selector string, options ...PageClickOptions)
      Frame.Click(selector string, options ...FrameClickOptions)
    • Some parameters are generated as new types or names, e.g. Page.AddInitScript(script Script)
  • Removed several methods that were not documented upstream. These methods can be safely converted to other existing methods. For example
    • Page.ExpectedDialog can use Page.OnDialog instead.
    • All xxxAssertions.NotTo..., use .Not().xxx pls.

Copy link
Member

@mxschmitt mxschmitt left a comment

Choose a reason for hiding this comment

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

didn't do a line by line review but looks all reasonable.

@@ -22,7 +22,7 @@ func main() {
if err != nil {
log.Fatalf("could not create page: %v", err)
}
if _, err = page.Goto("http://whatsmyuseragent.org/", playwright.PageGotoOptions{
if _, err = page.Goto("https://playwright.dev/", playwright.PageGotoOptions{
// networkidle is DISCOURAGED
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// networkidle is DISCOURAGED

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will do this in next pr.

RecordVideo: &playwright.RecordVideo{
Dir: playwright.String("videos/"),
Copy link
Member

Choose a reason for hiding this comment

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

I in the past used it to differentiate if a user did set a string, since in Go a String can't be nil.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

According to the documentation, recordVideo itself can be nil, and path is required once the recordVideo parameter is provided. When generating type members, the script will judge whether the primitive type needs to be referenced by pointer or not.

## context-option-recordvideo
* langs: js
- `recordVideo` <[Object]>
  - `dir` <[path]> Path to the directory to put videos into.
  - `size` ?<[Object]> Optional dimensions of the recorded videos. If not specified the size will be equal to `viewport`
    scaled down to fit into 800x800. If `viewport` is not configured explicitly the video size defaults to 800x450.
    Actual picture of each page will be scaled down if necessary to fit the specified size.
    - `width` <[int]> Video frame width.
    - `height` <[int]> Video frame height.

@mxschmitt
Copy link
Member

Impressive work, thanks for putting effort into this.

@canstand canstand merged commit d1bed75 into playwright-community:main Aug 24, 2023
13 checks passed
@canstand canstand deleted the codegen branch August 24, 2023 06:18
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.

None yet

2 participants