2019-11-02 14:32:58 +00:00
|
|
|
package suites
|
|
|
|
|
2019-11-24 20:27:59 +00:00
|
|
|
import (
|
2021-11-05 13:14:42 +00:00
|
|
|
"fmt"
|
2019-11-24 20:27:59 +00:00
|
|
|
"strings"
|
|
|
|
"testing"
|
2019-11-02 14:32:58 +00:00
|
|
|
|
2021-11-05 13:14:42 +00:00
|
|
|
"github.com/go-rod/rod"
|
|
|
|
"github.com/stretchr/testify/assert"
|
2019-11-24 20:27:59 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2021-11-05 13:14:42 +00:00
|
|
|
func (rs *RodSession) verifyBodyContains(t *testing.T, page *rod.Page, pattern string) {
|
|
|
|
body, err := page.Element("body")
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, body)
|
2019-11-30 16:49:52 +00:00
|
|
|
|
2021-11-05 13:14:42 +00:00
|
|
|
text, err := body.Text()
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, text)
|
2019-11-30 16:49:52 +00:00
|
|
|
|
2021-11-05 13:14:42 +00:00
|
|
|
if strings.Contains(text, pattern) {
|
|
|
|
err = nil
|
|
|
|
} else {
|
|
|
|
err = fmt.Errorf("body does not contain pattern: %s", pattern)
|
|
|
|
}
|
2019-11-24 20:27:59 +00:00
|
|
|
|
|
|
|
require.NoError(t, err)
|
2019-11-02 14:32:58 +00:00
|
|
|
}
|