/** * @issue https://github.com/Codeception/Codeception/issues/2841 */ public function testSubmitFormDoesNotKeepGetParameters() { $this->module->amOnPage('/form/bug2841?stuff=other'); $this->module->fillField('#texty', 'thingshjere'); $this->module->click('#submit-registration'); $this->assertEmpty(data::get('query'), 'Query string is not empty'); }
public function testSwitchToIframe() { $this->module->amOnPage('/iframe'); $this->module->switchToIframe('content'); $this->module->see('Is that interesting?'); $this->module->click('Ссылочка'); }
public function testLoginToFacebook() { $this->markTestSkipped(); // preconditions: #1 php web server being run $browserModule = new PhpBrowser(); $browserModule->_setConfig(array('url' => 'http://localhost:8000')); $browserModule->_initialize(); $browserModule->_cleanup(); $browserModule->_before($this->makeTest()); SuiteManager::$modules['PhpBrowser'] = $browserModule; // preconditions: #2 facebook test user was created $this->module->haveFacebookTestUserAccount(); $testUserFirstName = $this->module->grabFacebookTestUserFirstName(); // preconditions: #3 test user logged in on facebook $this->module->haveTestUserLoggedInOnFacebook(); // go to our page with facebook login button $browserModule->amOnPage('/facebook'); // check that yet we are not logged in with facebook $browserModule->see('You are not Connected.'); // click on "Login with Facebook" button to start login with facebook $browserModule->click('Login with Facebook'); // check that we are logged in with facebook $browserModule->see('Your User Object (/me)'); $browserModule->see($testUserFirstName); // cleanup unset(SuiteManager::$modules['PhpBrowser']); $browserModule->_after($this->makeTest()); data::clean(); }
/** * If we have a form with fields like * ``` * <input type="file" name="foo" /> * <input type="file" name="foo[bar]" /> * ``` * then only array variable will be used while simple variable will be ignored in php $_FILES * (eg $_FILES = [ * foo => [ * tmp_name => [ * 'bar' => 'asdf' * ], * //... * ] * ] * ) * (notice there is no entry for file "foo", only for file "foo[bar]" * this will check if current element contains inner arrays within it's keys * so we can ignore element itself and only process inner files */ public function testFormWithFilesInOnlyArray() { $this->shouldFail(); $this->module->amOnPage('/form/example13'); $this->module->attachFile('foo', 'app/avatar.jpg'); $this->module->attachFile('foo[bar]', 'app/avatar.jpg'); $this->module->click('Submit'); }
public function testSelectOptionValueSelector() { $this->module->amOnPage('/form/select_selectors'); $this->module->selectOption('age', ['value' => '20']); $this->module->click('Submit'); $data = data::get('form'); $this->assertEquals('20', $data['age']); }
/** * https://github.com/Codeception/Codeception/issues/1098 */ public function testExample5() { $this->module->amOnPage('/form/example5'); $this->module->fillField('username', 'John'); $this->module->fillField('password', '1234'); $this->module->click('Login'); $this->module->seeCurrentUrlEquals('/form/example5?username=John&password=1234'); }
public function testFillFieldWithAmpersand() { $this->module->amOnPage('/form/field'); $this->module->fillField('Name', 'this & that'); $this->module->click('Submit'); $form = data::get('form'); $this->assertEquals('this & that', $form['name']); }
public function testLinksWithDifferentContext() { $this->module->amOnPage('/'); $this->module->click('Test', '#area1'); $this->module->seeInCurrentUrl('/form/file'); $this->module->amOnPage('/'); $this->module->click('Test', '#area2'); $this->module->seeInCurrentUrl('/form/hidden'); }
public function testLoadPageApi() { $this->module->_loadPage('POST', '/form/try', ['user' => 'davert']); $data = data::get('form'); $this->assertEquals('davert', $data['user']); $this->module->see('Welcome to test app'); $this->module->click('More info'); $this->module->seeInCurrentUrl('/info'); }
public function testLinksWithSimilarNames() { $this->module->amOnPage('/'); $this->module->click('Test Link'); $this->module->seeInCurrentUrl('/form/file'); $this->module->amOnPage('/'); $this->module->click('Test'); $this->module->seeInCurrentUrl('/form/hidden'); }
public function testFormWithFileSpecialCharNames() { $this->module->amOnPage('/form/example14'); $this->module->attachFile('foo bar', 'app/avatar.jpg'); $this->module->attachFile('foo.baz', 'app/avatar.jpg'); $this->module->click('Submit'); $this->assertNotEmpty(data::get('files')); $files = data::get('files'); $this->assertNotEmpty($files); $this->assertArrayHasKey('foo_bar', $files); $this->assertArrayHasKey('foo_baz', $files); }
/** * @Issue https://github.com/Codeception/Codeception/issues/1585 * @Issue https://github.com/Codeception/Codeception/issues/1602 */ public function testUnreachableField() { $this->module->amOnPage('/form/bug1585'); $this->module->fillField('textarea[name="captions[]"]', 'test2'); $this->module->fillField('items[1][]', 'test3'); $this->module->fillField('input[name="users[]"]', 'davert'); $this->module->attachFile('input[name="files[]"]', 'app/avatar.jpg'); $this->module->click('Submit'); $data = data::get('form'); $this->assertContains('test3', $data['items'][1]); $this->assertContains('test2', $data['captions']); $this->assertContains('davert', $data['users']); }
public function testLinksWithNonLatin() { $this->module->amOnPage('/info'); $this->module->seeLink('Ссылочка'); $this->module->click('Ссылочка'); }
/** * @issue https://github.com/Codeception/Codeception/issues/2408 */ public function testClickFailure() { $this->module->amOnPage('/info'); $this->setExpectedException('Codeception\\Exception\\ElementNotFound', "'Sign In!' is invalid CSS and XPath selector and Link or Button element with 'name=Sign In!' was not found"); $this->module->click('Sign In!'); }
private function loginToFacebook(PhpBrowser $browserModule) { // preconditions: #1 facebook test user is created $this->module->haveFacebookTestUserAccount(); $testUserName = $this->module->grabFacebookTestUserName(); // preconditions: #2 test user is logged in on facebook $this->module->haveTestUserLoggedInOnFacebook(); // go to our page with facebook login button $browserModule->amOnPage('/facebook'); // check that yet we are not logged in on facebook $browserModule->see('You are not Connected.'); // click on "Login with Facebook" button to start login with facebook $browserModule->click('Login with Facebook'); // check that we are logged in with facebook $browserModule->see('Your User Object (/me)'); $browserModule->see($testUserName); }