@@ -736,6 +736,42 @@ public function i_set_the_following_fields_to_these_values_in_the_app(TableNode
736736 }
737737 }
738738
739+ /**
740+ * Checks a field matches a certain value in the app.
741+ *
742+ * Currently this only works for input fields which must be identified using a partial or
743+ * exact match on the placeholder text.
744+ *
745+ * @Given /^the field "((?:[^"]|\\")+)" matches value "((?:[^"]|\\")*)" in the app$/
746+ * @param string $field Text identifying field
747+ * @param string $value Value for field
748+ * @throws DriverException If the field isn't found
749+ * @throws ExpectationException If the field value is different to the expected value
750+ */
751+ public function the_field_matches_value_in_the_app (string $ field , string $ value ) {
752+ $ field = addslashes_js ($ field );
753+ $ value = addslashes_js ($ value );
754+
755+ $ this ->spin (function () use ($ field , $ value ) {
756+ $ result = $ this ->runtime_js ("fieldMatches(' $ field', ' $ value') " );
757+
758+ if ($ result !== 'OK ' ) {
759+ if (str_contains ($ result , 'No element matches ' )) {
760+ throw new DriverException ('Error field matches value - ' . $ result );
761+ } else {
762+ throw new ExpectationException (
763+ 'Error field matches value - ' . $ result ,
764+ $ this ->getSession ()->getDriver ()
765+ );
766+ }
767+ }
768+
769+ return true ;
770+ });
771+
772+ $ this ->wait_for_pending_js ();
773+ }
774+
739775 /**
740776 * Checks that the current header stripe in the app contains the expected text.
741777 *
@@ -912,4 +948,17 @@ public function i_switch_network_connection(string $mode) {
912948 }
913949 }
914950
951+ /**
952+ * Open a browser tab with a certain URL.
953+ *
954+ * @Then /^I open a browser tab with url "(?P<pattern>[^"]+)"$/
955+ * @param string $url URL
956+ */
957+ public function i_open_a_browser_tab_with_url (string $ url ) {
958+ $ this ->execute_script ("window.open(' $ url', '_system'); " );
959+
960+ $ windowNames = $ this ->getSession ()->getWindowNames ();
961+ $ this ->getSession ()->switchToWindow ($ windowNames [1 ]);
962+ }
963+
915964}
0 commit comments