
diff --git a/message/tests/behat/behat_message.php b/message/tests/behat/behat_message.php
index 7aff12b9a5a..c8f2a8c2ee9 100644
--- a/message/tests/behat/behat_message.php
+++ b/message/tests/behat/behat_message.php
@@ -44,6 +44,30 @@ class behat_message extends behat_base {
* @param string $userfullname
*/
public function i_view_contact_in_messages($userfullname) {
+ // Visit home page and follow messages.
+ $this->i_select_user_in_messaging($userfullname);
+
+ $this->execute('behat_general::i_click_on_in_the',
+ array(
+ "//button[@data-action='view-contact-profile']
+ [contains(normalize-space(.), '" . $this->escape($userfullname) . "')]",
+ 'xpath_element',
+ ".messages-header",
+ "css_element",
+ )
+ );
+
+ $this->execute('behat_general::wait_until_the_page_is_ready');
+ }
+
+ /**
+ * Select a user in the messaging UI.
+ *
+ * @Given /^I select "(?P
(?:[^"]|\\")*)" user in messaging$/
+ * @param string $userfullname
+ */
+ public function i_select_user_in_messaging($userfullname) {
+
// Visit home page and follow messages.
$this->execute("behat_general::i_am_on_homepage");
@@ -63,7 +87,7 @@ class behat_message extends behat_base {
// can occur in two separate divs on the page.
$this->execute('behat_general::i_click_on_in_the',
array(
- "//div[@data-action='view-contact-profile']
+ "//div[@data-action='view-contact-msg']
[./div[contains(normalize-space(.), '" . $this->escape($userfullname) . "')]]",
'xpath_element',
"[data-region='messaging-area'] [data-region='search-results-area']",
@@ -74,6 +98,7 @@ class behat_message extends behat_base {
$this->execute('behat_general::wait_until_the_page_is_ready');
}
+
/**
* Sends a message to the specified user from the logged user. The user full name should contain the first and last names.
*
@@ -82,11 +107,7 @@ class behat_message extends behat_base {
* @param string $userfullname
*/
public function i_send_message_to_user($messagecontent, $userfullname) {
- $this->i_view_contact_in_messages($userfullname);
-
- $this->execute("behat_general::i_click_on", array("[data-action='profile-send-message']", 'css_element'));
-
- $this->execute('behat_general::wait_until_the_page_is_ready');
+ $this->i_select_user_in_messaging($userfullname);
$this->execute('behat_forms::i_set_the_field_with_xpath_to',
array("//textarea[@data-region='send-message-txt']", $this->escape($messagecontent))