diff --git a/README.md b/README.md index 0b2a179..34c343f 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/playwright.go b/playwright.go index 2c6a2ba..5bf9c03 100644 --- a/playwright.go +++ b/playwright.go @@ -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; } \ No newline at end of file