matchRegexp is a chromedp.Action that fetches the text of the first node that matched query and checks that the text matches regexp re.
(t *testing.T, query, re string)
| 136 | // matchRegexp is a chromedp.Action that fetches the text of the first |
| 137 | // node that matched query and checks that the text matches regexp re. |
| 138 | func matchRegexp(t *testing.T, query, re string) chromedp.ActionFunc { |
| 139 | return func(ctx context.Context) error { |
| 140 | var value string |
| 141 | err := chromedp.Text(query, &value, chromedp.ByQuery).Do(ctx) |
| 142 | if err != nil { |
| 143 | return fmt.Errorf("text %s: %v", query, err) |
| 144 | } |
| 145 | t.Logf("text %s:\n%s", query, value) |
| 146 | m, err := regexp.MatchString(re, value) |
| 147 | if err != nil { |
| 148 | return err |
| 149 | } |
| 150 | if !m { |
| 151 | return fmt.Errorf("%s: did not find %q in\n%s", query, re, value) |
| 152 | } |
| 153 | return nil |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | // matchInOrder is a chromedp.Action that fetches the text of the first |
| 158 | // node that matched query and checks that the supplied sequence of |
no outgoing calls
no test coverage detected
searching dependent graphs…