2019-11-02 21:32:58 +07:00
|
|
|
package suites
|
|
|
|
|
2019-11-25 03:27:59 +07:00
|
|
|
import (
|
2021-11-05 20:14:42 +07:00
|
|
|
"fmt"
|
2019-11-25 03:27:59 +07:00
|
|
|
"strings"
|
|
|
|
"testing"
|
2019-11-02 21:32:58 +07:00
|
|
|
|
2021-11-05 20:14:42 +07:00
|
|
|
"github.com/go-rod/rod"
|
|
|
|
"github.com/stretchr/testify/assert"
|
2019-11-25 03:27:59 +07:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2021-11-05 20:14:42 +07: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 23:49:52 +07:00
|
|
|
|
2021-11-05 20:14:42 +07:00
|
|
|
text, err := body.Text()
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, text)
|
2019-11-30 23:49:52 +07:00
|
|
|
|
2021-11-05 20:14:42 +07:00
|
|
|
if strings.Contains(text, pattern) {
|
|
|
|
err = nil
|
|
|
|
} else {
|
|
|
|
err = fmt.Errorf("body does not contain pattern: %s", pattern)
|
|
|
|
}
|
2019-11-25 03:27:59 +07:00
|
|
|
|
|
|
|
require.NoError(t, err)
|
2019-11-02 21:32:58 +07:00
|
|
|
}
|