Skip to content

Commit

Permalink
Add locator.Clear tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur22 committed Jan 10, 2024
1 parent c0ab091 commit b7543e6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/locator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tests

import (
"testing"
"time"

"github.com/dop251/goja"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -53,6 +54,19 @@ func TestLocator(t *testing.T) {
})
},
},
{
"Clear", func(tb *testBrowser, p *common.Page) {
const value = "fill me up"
l := p.Locator("#inputText", nil)

l.Fill(value, nil)
require.Equal(t, value, p.InputValue("#inputText", nil))

err := l.Clear(common.NewFrameFillOptions(l.Timeout()))
assert.NoError(t, err)
assert.Equal(t, "", p.InputValue("#inputText", nil))
},
},
{
"Click", func(tb *testBrowser, p *common.Page) {
err := p.Locator("#link", nil).Click(nil)
Expand Down Expand Up @@ -235,6 +249,15 @@ func TestLocator(t *testing.T) {
{
"Check", func(l *common.Locator, tb *testBrowser) { l.Check(timeout(tb)) },
},
{
"Clear", func(l *common.Locator, tb *testBrowser) {
err := l.Clear(common.NewFrameFillOptions(100 * time.Millisecond))
if err != nil {
// TODO: remove panic and update tests when all locator methods return error.
panic(err)
}
},
},
{
"Click", func(l *common.Locator, tb *testBrowser) {
err := l.Click(timeout(tb))
Expand Down

0 comments on commit b7543e6

Please sign in to comment.