Skip to content

Commit

Permalink
feat: added the evaluate action for pages, updated readme accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasvuono committed Feb 22, 2022
1 parent 1fe4d1a commit e7a847b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export default function () {
| focus() | [`Focus()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Page.Focus) | focuses a spcific element based on the provided selector |
| fill() | [`Fill()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Page.Fill) | fills an 'input' element on the page based on the provided selector and string to be entered |
| dragAndDrop() | [`DragAndDrop()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Page.DragAndDrop) | drag an item from one place to another based on two selectors |
| evaluate() | [`Evaluate()`](https://pkg.go.dev/github.com/mxschmitt/playwright-go#Page.Evaluate) | evaluate an expresion or function and get the return value |


NOTE: the above 'Encompassed Playwright Function(s)' will link to the [playwright-go package documentation](https://pkg.go.dev/github.com/mxschmitt/playwright-go#section-readme) to give an in-depth overview of how these functions will behave from a low-level perspective.
Expand Down
9 changes: 9 additions & 0 deletions playwright.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,13 @@ func (p *Playwright) DragAndDrop(sourceSelector string, targetSelector string, o
if err := p.Page.DragAndDrop(sourceSelector, targetSelector, opts); err != nil {
log.Fatalf("error with drag and drop: %v", err)
}
}

//Evaluate wrapper around playwright evaluate page function that takes in an expresion and a set of options and evaluates the expression/function returning the resulting information.
func (p *Playwright) Evaluate(expression string, opts playwright.PageEvaluateOptions) interface{} {
returnedValue, err := p.Page.Evaluate(expression, opts);
if err != nil {
log.Fatalf("error evaluating the expression: %v", err)
}
return returnedValue;
}

0 comments on commit e7a847b

Please sign in to comment.