public function administratorCreateCategoryWithoutTitleFails(AcceptanceTester $I) { $I->am('Administrator'); $I->wantToTest('Category creation in /administrator/ without title fails'); $I->doAdministratorLogin(); $I->amGoingTo('Navigate to Categories page in /administrator/'); $I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks'); $I->waitForText('Weblinks: Categories', '60', ['css' => 'h1']); $I->expectTo('see categories page'); $I->amGoingTo('try to save a category with empty title and it should fail'); $I->clickToolbarButton('new'); $I->waitForText('Weblinks: New Category', '60', ['css' => 'h1']); $I->clickToolbarButton('save'); $I->expectTo('see an error when trying to save a category without title'); $I->see('Invalid field: Title', ['id' => 'system-message-container']); }
public function ensureThatLoginWorks(AcceptanceTester $I) { $I->amOnPage(Url::toRoute('/user/login')); $I->see('Login', 'h1'); $I->amGoingTo('try to login with correct credentials'); $I->fillField('input[name="LoginForm[username]"]', 'admin'); $I->fillField('input[name="LoginForm[password]"]', 'admin'); $I->click('login-button'); $I->wait(2); // wait for button to be clicked $I->expectTo('see user info'); $I->see('Logout'); }
public function doFindTable(\AcceptanceTester $I) { $I->amGoingTo('find a table in the selected restaurant'); $I->lookForwardTo('reserve a reservation time slot'); $I->amOnPage('/reservation'); $I->seeElement('.panel-find-table'); $I->selectOption('location', 'Lewisham'); $I->selectOption('guest_num', '4'); $I->fillField('reserve_date', date('d-m-Y', strtotime('+ 1 month', time()))); $I->fillField('reserve_time', '2:45 PM'); $I->click('Find Table', '#find-table-form'); $I->expect('success with available reservation times slot displayed'); $I->seeElement('.panel-time-slots'); $I->seeNumberOfElements('#time-slots .btn-group > .btn', 5); // 5 elements $I->click('#time-slots .btn-group > .btn:nth-child(4)'); $I->click('Select Time', '#find-table-form'); $I->expectTo('see the reservation summary'); $I->seeElement('.panel-summary'); }
public function administratorUnpublishCategory(AcceptanceTester $I) { $I->am('Administrator'); $I->wantToTest('Category unpublishing in /administrator/'); $I->doAdministratorLogin(); $I->amGoingTo('Navigate to Categories page in /administrator/'); $I->amOnPage('administrator/index.php?option=com_categories&extension=com_weblinks'); $I->waitForText('Weblinks: Categories', '30', ['css' => 'h1']); $I->expectTo('see categories page'); $I->checkForPhpNoticesOrWarnings(); $I->amGoingTo('try to save a category with a filled title'); $I->click(['xpath' => "//button[@onclick=\"Joomla.submitbutton('category.add')\"]"]); $I->waitForText('Category Manager: Add A New Weblinks Category', '30', ['css' => 'h1']); $I->fillField(['id' => 'jform_title'], 'automated testing unpub' . rand(1, 100)); $I->click(['xpath' => "//button[@onclick=\"Joomla.submitbutton('category.save')\"]"]); $I->expectTo('see a success message after saving the category'); $I->see('Category successfully saved', ['id' => 'system-message-container']); $I->amGoingTo('Search for automated testing'); $I->fillField(['xpath' => "//input[@id=\"filter_search\"]"], "automated testing unpub" . "\n"); $I->waitForText('Weblinks: Categories', '30', ['css' => 'h1']); $I->amGoingTo('Select the first weblink'); $I->click(['xpath' => "//input[@id=\"cb0\"]"]); $I->amGoingTo('Try to publish a weblink category'); $I->click(['xpath' => "//button[@onclick=\"if (document.adminForm.boxchecked.value==0){alert('Please first make a selection from the list.');}else{ Joomla.submitbutton('categories.publish')}\"]"]); $I->waitForText('Weblinks: Categories', '30', ['css' => 'h1']); $I->expectTo('See a success message after publishing the category'); $I->see('1 category successfully published.', ['id' => 'system-message-container']); // Unpublish it again $I->waitForText('Weblinks: Categories', '30', ['css' => 'h1']); $I->amGoingTo('Select the first weblink'); $I->click(['xpath' => "//input[@id=\"cb0\"]"]); $I->amGoingTo('Try to unpublish a weblink category'); $I->click(['xpath' => "//button[@onclick=\"if (document.adminForm.boxchecked.value==0){alert('Please first make a selection from the list.');}else{ Joomla.submitbutton('categories.unpublish')}\"]"]); $I->waitForText('Weblinks: Categories', '30', ['css' => 'h1']); $I->expectTo('See a success message after unpublishing the category'); $I->see('1 category successfully unpublished', ['id' => 'system-message-container']); }
<?php /* @var $scenario Codeception\Scenario */ $I = new AcceptanceTester($scenario); $I->wantTo('Memastikan "Employee" bekerja'); /* TESTING INDEX EMPLOYEE */ $I->amGoingTo('cek halaman daftar employee'); $I->amOnPage('employee/index'); $I->expectTo('judul halaman "Daftar Employee", dan tombol Create'); $I->see('Daftar Employee', 'h1'); $I->see('CREATE', 'a'); /* TESTING CREATE EMPLOYEE */ $I->wantTo('Memastikan "Create Employee" bekerja'); $I->amGoingTo('cek halaman create employee'); $I->amOnPage('employee/create'); $I->see('Employee', 'h1'); $I->see('SIMPAN', 'button'); $I->seeElement('input', ['name' => 'Employee[name]']); $I->seeElement('input', ['name' => 'Employee[age]']); $I->amGoingTo('submit form dengan data input kosong'); $I->click('button[type="submit"]'); $I->expectTo('Validasi eror muncul!'); $I->see('Name cannot be blank.'); $I->see('Age cannot be blank.'); $I->amGoingTo('submit form dengan data data'); $I->fillField('input[name="Employee[name]"]', 'Hafid'); $I->fillField('input[name="Employee[age]"]', '30'); $I->click('button[type="submit"]'); $I->expectTo('submit form berhasil'); $I->see('Data berhasil disimpan');
/** * Tests Checkout Success page * * @group checkout * * @param $I AcceptanceTester * * @depends testOnePageCheckout */ public function testOnePageCheckoutSuccess(AT $I) { $I->wantTo('Observe the order success page'); $I->expectTo('see order success page'); $I->seeInCurrentUrl(Page\Checkout::$SUCCESS_URL); $I->expectTo('be a happy customer'); }
<?php $I = new AcceptanceTester($scenario); $I->am('Google Bot'); $I->wantTo('Test XML Sitemaps'); $I->expectTo('see the sitemap in robots.txt'); $I->sendGET('/robots.txt'); $I->seeResponseContains('Sitemap:'); $I->seeResponseContains('/sitemap.xml'); $I->seeResponseContains('/sitemapindex.xml'); $I->expectTo('see an XML sitemap index'); $I->sendGET('/sitemapindex.xml'); $I->seeResponseCodeIs(200); $I->haveHttpHeader('Content-Type', 'application/xml; charset=utf-8'); $I->seeResponseIsXml(); $I->dontSee('<b>Notice</b>'); $I->dontSee('error'); $I->expectTo('see a brief XML sitemap'); $I->sendGET('/sitemap.xml'); $I->seeResponseCodeIs(200); $I->seeResponseIsXml(); $I->haveHttpHeader('Content-Type', 'application/xml; charset=utf-8'); $I->seeResponseContains('<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"'); $I->dontSee('<b>Notice</b>'); // error sometimes thrown if Wordpress timezone not set $I->dontSee('error'); $I->expectTo('see a paginated XML sitemap'); $I->sendGET('/sitemap.xml?page=1'); $I->seeResponseCodeIs(200); $I->seeResponseIsXml(); $I->haveHttpHeader('Content-Type', 'application/xml; charset=utf-8');
public function administratorCreateWeblinkWithoutTitleFails(AcceptanceTester $I) { $I->am('Administrator'); $I->wantToTest('Weblink creation without title fails in /administrator/'); $I->doAdministratorLogin(); $I->amGoingTo('Navigate to Weblinks page in /administrator/'); $I->amOnPage('administrator/index.php?option=com_weblinks'); $I->waitForText('Web Links', '30', ['css' => 'h1']); $I->expectTo('see weblinks page'); $I->checkForPhpNoticesOrWarnings(); $I->amGoingTo('try to save a weblink with empty title and it should fail'); $I->click(['xpath' => "//button[@onclick=\"Joomla.submitbutton('weblink.add')\"]"]); $I->waitForText('Web Link: New', '30', ['css' => 'h1']); $I->click(['xpath' => "//button[@onclick=\"Joomla.submitbutton('weblink.apply')\"]"]); $I->expectTo('see an error when trying to save a weblink without title and without URL'); $I->see('Invalid field: Title', ['id' => 'system-message-container']); $I->see('Invalid field: URL', ['id' => 'system-message-container']); }
<?php $I = new AcceptanceTester($scenario); $I->am('a visitor'); $I->amGoingTo('register as a user that already exists'); $I->lookForwardTo('see the error message after trying to register'); $I->amOnPage('/oc-panel/auth/register'); $I->fillField('name', 'user'); $I->fillField(".register input[name='email']", '*****@*****.**'); $I->fillField('password1', 'user'); $I->fillField('password2', 'user'); $I->click(".register button[type=submit]"); $I->expectTo('see success message'); $I->see('welcome'); $I->amOnPage('/'); $I->click('Logout'); $I->amGoingTo('register as a user that already exists'); $I->lookForwardTo('see the error message after trying to register'); $I->amOnPage('/oc-panel/auth/register'); $I->fillField('name', 'Jermain Doe'); $I->fillField(".register input[name='email']", '*****@*****.**'); $I->fillField('password1', '1234'); $I->fillField('password2', '1234'); $I->click(".register button[type=submit]"); $I->expectTo('see error message'); $I->see('User already exists'); $I->amGoingTo('register without filling Name field'); $I->fillField('name', ''); $I->fillField(".register input[name='email']", '*****@*****.**'); $I->fillField('password1', '123456'); $I->fillField('password2', '123456');
<?php // @group onlyCrud use tests\_pages\LoginPage; $I = new AcceptanceTester($scenario); $I->wantTo('ensure that crudOnly works (no access rules)'); $I->amOnPage('/onlyCrud/country'); $I->see('Countries', 'h1'); $I->makeScreenshot('crud-country'); $I->expectTo('see view, edit and delete button'); $I->seeElementInDOM('[data-key="1"] .glyphicon-file'); $I->seeElementInDOM('[data-key="2"] .glyphicon-pencil'); $I->seeElementInDOM('[data-key="3"] .glyphicon-trash'); $I->amGoingTo('create a Country'); $I->click('New'); $I->see('Country', 'h1'); $I->see('Create', '.btn'); $I->fillField('#country-country', 'Xyzland'); $I->makeScreenshot('crud-pre-create-country'); $I->click('Create'); $I->wait(1); $I->see('Xyzland', 'table'); $I->see('Country', 'table'); $I->makeScreenshot('crud-create-country'); $I->click('Edit'); $I->wait(1); $I->seeInField('#country-country', 'Xyzland'); $I->see('Country', 'h1'); $I->fillField('#country-country', 'Abcstan'); $I->click('Save'); $I->wait(1);
<?php $I = new AcceptanceTester($scenario); $I->wantTo("make live changes to an existing article"); $I->loginAs("*****@*****.**", "secret"); // see I'm on the dashboard and click to edit the article $I->expectTo("see the article I want to edit in the article index"); $I->see("Foo Test", "#foo-test .edit-title"); // see I'm on the editing frame, wait for the iframe content to appear $I->expectTo("see the article I'm editing appear in the preview frame"); $I->see("Editing Frame"); $I->switchToIFrame("editing_iframe"); $I->waitForElement(".title"); $I->see("Foo Test", ".title"); $I->see("foo article abstract content", ".abstract"); // see that the content in the editing field matches the iframe content $I->expectTo("see the content in the editing field match the article preview"); $I->switchToIFrame(); $I->seeInField("input#title_input", "Foo Test"); // make a change to a default field (always visible) $I->amGoingto("change the title"); $I->switchToIframe(); $I->seeInField("#title_input", "Foo Test"); $I->fillField("#title_input", "New Title"); // see change in iframe $I->expectTo("see the change I made reflected in the preview frame"); $I->switchToIFrame("editing_iframe"); $I->see("New Title", ".title"); // make a change to a dynamic field (stored in Field db) $I->amGoingTo("change the xxx field"); $I->switchToIframe();
<?php $I = new AcceptanceTester($scenario); $I->wantTo("make sure the edit view loads the correct feilds"); $I->loginAs("*****@*****.**", "secret"); $I->amOnPage('/spectre/foo-test'); // make sure the data loads correctly in the iframe $I->expectTo("see the article I'm editing appear in the preview frame"); $I->see("Editing Frame"); $I->switchToIFrame("editing_iframe"); $I->waitForElement(".title"); $I->see("Foo Test", ".title"); $I->see("foo article abstract content", ".abstract"); // make sure the data loads in the editing frame $I->expectTo("see the content in the editing field match the article preview"); $I->switchToIFrame(); $I->seeInField("input#title_input", "Foo Test"); $I->seeInField("#abstract_input", "foo article abstract content");
<?php $I = new AcceptanceTester($scenario); $I->wantTo("create a new article"); $I->loginAs("*****@*****.**", "secret"); // see I'm on the dashboard and click to create a new article $I->expectTo("see a link to make a new article"); $I->see("New Post", "a"); $I->click("New Post"); // see that a new post appears in the iframe $I->expectTo("see a blank post template in the preview frame"); $I->see("Editing Frame"); $I->switchToIFrame("editing_iframe"); $I->waitForElement(".title"); $I->see("", ".title"); // set the article title $I->amGoingTo("change the title"); $I->switchToIFrame(); $I->fillField("#title_input", "Brand New Post"); // set the article slug $I->amGoingTo("set the slug"); $I->fillField("#slug_input", "brand-new-post"); // see changes in iframe $I->expectTo("see new title in the preview"); $I->switchToIFrame("editing_iframe"); $I->see("Brand New Post", ".title"); // save changes $I->amGoingTo("save changes"); $I->switchToIFrame(); $I->click("Save"); // see new article in dashboard