Mercurial > hg > isophonics-drupal-site
comparison core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
98 return NULL; | 98 return NULL; |
99 }); | 99 }); |
100 | 100 |
101 return $result; | 101 return $result; |
102 } | 102 } |
103 | |
104 /** | |
105 * Waits for the specified text and returns its element when available. | |
106 * | |
107 * @param string $text | |
108 * The text to wait for. | |
109 * @param int $timeout | |
110 * (Optional) Timeout in milliseconds, defaults to 10000. | |
111 * | |
112 * @return \Behat\Mink\Element\NodeElement|null | |
113 * The page element node if found and visible, NULL if not. | |
114 */ | |
115 public function waitForText($text, $timeout = 10000) { | |
116 $page = $this->session->getPage(); | |
117 return $page->waitFor($timeout / 1000, function () use ($page, $text) { | |
118 $actual = preg_replace('/\s+/u', ' ', $page->getText()); | |
119 $regex = '/' . preg_quote($text, '/') . '/ui'; | |
120 return (bool) preg_match($regex, $actual); | |
121 }); | |
122 } | |
123 | |
103 /** | 124 /** |
104 * Waits for a button (input[type=submit|image|button|reset], button) with | 125 * Waits for a button (input[type=submit|image|button|reset], button) with |
105 * specified locator and returns it. | 126 * specified locator and returns it. |
106 * | 127 * |
107 * @param string $locator | 128 * @param string $locator |