Skip to content

Conversation

masaushi
Copy link
Contributor

This is implementation for Locator (#238).
Please review the implementations.

thank you!

Copy link
Collaborator

@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.

@masaushi you did an amazing job there, I really appreciate your time and effort which you put into this! 💯

Thank you for contributing to the project, all the comments are just small nits + the patch files seem broken, maybe out of date, I can take a look at it if you struggle let me know!

frame.go Outdated
}

func (f *frameImpl) queryCount(selector string) (int, error) {
channel, err := f.channel.Send("queryCount", map[string]interface{}{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
channel, err := f.channel.Send("queryCount", map[string]interface{}{
response, err := f.channel.Send("queryCount", map[string]interface{}{

var option *LocatorLocatorOptions
if len(options) == 1 {
option = &options[0]
if option.HasText != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

in other typed language bindings (java, dotnet) we introduced options.HasTextRegex and options.HasTextString. But I think its fine for us to keep it like you did.

locator.go Outdated
return result, nil
}

func (l *locatorImpl) BoundingBox(options ...LocatorBoundingBoxOptions) (*LocatorBoundingBoxResult, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
func (l *locatorImpl) BoundingBox(options ...LocatorBoundingBoxOptions) (*LocatorBoundingBoxResult, error) {
func (l *locatorImpl) BoundingBox(options ...LocatorBoundingBoxOptions) (*Rect, error) {

locator.go Outdated
Comment on lines 129 to 130
strict := true
options[0].Strict = &strict
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
strict := true
options[0].Strict = &strict
options[0].Strict = Bool(true)

I think we have a wrapper function for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't know that useful wrapper function!
fixed codes including similar to this!

locator.go Outdated
}

var result interface{}
err := l.withElement(func(handle ElementHandle) (err error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

in theory we could change withElement that it returns (error, interface{}) so we don't need to have the outer variable assignment. Not sure tho if thats better!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, your suggestion is right.
I changed withElement to return (interface{}, error)!

locator.go Outdated
func (l *locatorImpl) Hover(options ...PageHoverOptions) error {
if len(options) == 1 {
strict := true
options[0].Strict = &strict
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto etc. as per above with the Bool(true) comment.

require.ElementsMatch(t, []string{"A", "B", "C"}, innerHTML)
}

func TestLocatorAllTextContens(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
func TestLocatorAllTextContens(t *testing.T) {
func TestLocatorAllTextContents(t *testing.T) {

@masaushi
Copy link
Contributor Author

@mxschmitt
Thank you for your review and comments!
I fixed codes based on your comments, but I'm not sure if patch files are changed correctly.
So, please let me know if there is anything I need to fix!

@mxschmitt
Copy link
Collaborator

Amazing, bots are green and that means your patch related changes were good!

@mxschmitt mxschmitt merged commit 989def6 into playwright-community:main Apr 21, 2022
@masaushi masaushi deleted the locators branch June 14, 2022 14:46

func (l *locatorImpl) Fill(value string, options ...FrameFillOptions) error {
if len(options) == 1 {
options[0].Strict = Bool(true)

Choose a reason for hiding this comment

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

This forcefully overwrites whatever config that is passed in unless they pass 2 configs in. Is that intentional?

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.

3 participants