Skip to content

Commit

Permalink
Add Page.GetAttribute tests
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Jun 6, 2024
1 parent f7480ec commit 083279b
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1806,3 +1806,42 @@ func TestPageTargetBlank(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, "you clicked!", got)
}

func TestPageGetAttribute(t *testing.T) {
t.Parallel()

p := newTestBrowser(t).NewPage(nil)
err := p.SetContent(`<a id="el" href="null">Something</a>`, nil)
require.NoError(t, err)

got, ok, err := p.GetAttribute("#el", "href", nil)
require.NoError(t, err)
require.True(t, ok)
assert.Equal(t, "null", got)
}

func TestPageGetAttributeMissing(t *testing.T) {
t.Parallel()

p := newTestBrowser(t).NewPage(nil)
err := p.SetContent(`<a id="el">Something</a>`, nil)
require.NoError(t, err)

got, ok, err := p.GetAttribute("#el", "missing", nil)
require.NoError(t, err)
require.False(t, ok)
assert.Equal(t, "", got)
}

func TestPageGetAttributeEmpty(t *testing.T) {
t.Parallel()

p := newTestBrowser(t).NewPage(nil)
err := p.SetContent(`<a id="el" empty>Something</a>`, nil)
require.NoError(t, err)

got, ok, err := p.GetAttribute("#el", "empty", nil)
require.NoError(t, err)
require.True(t, ok)
assert.Equal(t, "", got)
}

0 comments on commit 083279b

Please sign in to comment.