amOnPage('/wp-login.php'); if ($this->loadSessionSnapshot('login')) { return; } $this->wait(1);// this needs to be here, Username is not filled properly without this line $this->fillField('Username', 'admin'); $this->fillField('Password', 'password'); $this->click('Log In'); $this->waitForText('MailPoet', 10); $this->saveSessionSnapshot('login'); } /** * Define custom actions here */ public function logOut() { $I = $this; $I->amOnPage('/wp-login.php?action=logout'); $I->click('log out'); $I->wait(1); } /** * Navigate to the specified Mailpoet page in the admin. * * @param string $page The page to visit e.g. Inbox or Status */ public function amOnMailpoetPage($page) { $I = $this; $I->amOnPage('/wp-admin'); $I->waitForText('MailPoet', 10); $I->click('MailPoet'); $I->waitForText($page, 5); $I->click($page); $I->waitForText($page, 5); } public function clickItemRowActionByItemName($item_name, $link) { $I = $this; $I->moveMouseOver(['xpath' => '//*[text()="' . $item_name . '"]//ancestor::tr']); $I->click($link, ['xpath' => '//*[text()="' . $item_name . '"]//ancestor::tr']); } /** * Select a value from select2 input field. * * @param string $value * @param string $element */ public function selectOptionInSelect2($value, $element = 'input.select2-search__field') { $I = $this; $I->fillField($element, $value); $I->pressKey($element, \WebDriverKeys::ENTER); } /** * Navigate to the editor for a newsletter. * * @param int $id */ public function amEditingNewsletter($id) { $I = $this; $I->amOnPage('/wp-admin/admin.php?page=mailpoet-newsletter-editor&id=' . $id); $I->waitForElement('[data-automation-id="newsletter_title"]'); } }