2019-11-02 14:32:58 +00:00
|
|
|
package suites
|
|
|
|
|
2019-11-24 20:27:59 +00:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
2019-11-02 14:32:58 +00:00
|
|
|
|
2019-11-24 20:27:59 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/tebeka/selenium"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (wds *WebDriverSession) verifyBodyContains(ctx context.Context, t *testing.T, pattern string) {
|
|
|
|
err := wds.Wait(ctx, func(wd selenium.WebDriver) (bool, error) {
|
2019-11-30 16:49:52 +00:00
|
|
|
bodyElement, err := wds.WebDriver.FindElement(selenium.ByTagName, "body")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if bodyElement == nil {
|
|
|
|
return false, nil
|
|
|
|
}
|
2019-11-24 20:27:59 +00:00
|
|
|
|
|
|
|
content, err := bodyElement.Text()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return strings.Contains(content, pattern), nil
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
2019-11-02 14:32:58 +00:00
|
|
|
}
|