codeception

Loop through links on a page in Codeception Tests

允我心安 提交于 2019-12-24 15:10:02
问题 I'm writing some functionality tests using Codeception and the PHPBrowser webdriver. Codeception uses specific references in CSS or XPath to check elements on a page. But I want to be able to loop through all the links in my menu, click on it and run a test to see if the link is working. ie. if my menu looks like this: <ul id='nav'> <li><a>Link1</a></li> <li><a>Link2</a></li> <li><a>Link3</a></li> <li><a>Link4</a></li> <li><a>Link5</a></li> </ul> I want to be able to loop through the links

Yii2: loading fixtures for specific functional tests

不羁的心 提交于 2019-12-24 13:19:34
问题 Short version: Using Yii2 Advanced Application Template and Codeception functional tests, is there a way to load a specific fixture only before a particular scenario (Cest class)? (Background / side note: I have a vague feeling I might be approaching this wrong, since arguably, if tests should be completely isolated with regards to db, they should be unit tests and not functional ones. However, due to time constraints on the project I started with functional tests while postponing unit

Selenium 3.0.1 with safaridriver failing on waitForElementVisible()

梦想的初衷 提交于 2019-12-24 05:22:05
问题 Safari 10.0.1 macOS Sierra When running Codeception command: $I->waitForElementVisible(['css' => 'input[type=text][id=UserUsername]'], 30); in an acceptance test in Safari with Selenium 3.0.1 I receive an error. The screenshot taken at failure clearly displays the element in question. The same test/command is successful in both Firefox and Chrome. The error: Screenshot saved to /Applications/MAMP/htdocs/AutomatedTests/tests/_output/debug/FAILED1479307207.png Unable to retrieve Selenium logs :

Selenium 3.0.1 with safaridriver failing on waitForElementVisible()

旧时模样 提交于 2019-12-24 05:22:03
问题 Safari 10.0.1 macOS Sierra When running Codeception command: $I->waitForElementVisible(['css' => 'input[type=text][id=UserUsername]'], 30); in an acceptance test in Safari with Selenium 3.0.1 I receive an error. The screenshot taken at failure clearly displays the element in question. The same test/command is successful in both Firefox and Chrome. The error: Screenshot saved to /Applications/MAMP/htdocs/AutomatedTests/tests/_output/debug/FAILED1479307207.png Unable to retrieve Selenium logs :

Send file to Restful service in codeception

核能气质少年 提交于 2019-12-23 15:19:28
问题 I would like to test restful API test for file uploading. I try to run: $I->sendPOST($this->endpoint, $postData, ['file' => 'example.jpg']); and I would like it to behave the same as user sent example.jpg file in file input with name file but it doesn't seem to work this way. I'm getting: [PHPUnit_Framework_ExceptionWrapper] An uploaded file must be an array or an instance of UploadedFile. Is it possible to upload file using REST plugin in codeception? Documentation is very limited and it's

Codeception not found Yii

邮差的信 提交于 2019-12-23 11:57:34
问题 I have tried to run unit tests in Yii2 project with using codecept. And received next error: PHP Fatal error: Class 'Yii' not found in /var/www/html/mysite/vendor/codeception/codeception/src/Codeception/Module/Yii2.php on line 77 It's my unit.suite.yml content: # Codeception Test Suite Configuration # suite for unit (internal) tests. # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. class_name: CodeGuy modules: enabled: [CodeHelper, Yii2] config: Yii2: configFile: 'config/web.php' Does

Switch IFrame with Codeception using ID

随声附和 提交于 2019-12-22 13:56:22
问题 How can I switch to an IFrame with Codeception using ID? Actually I can use the name of the IFrame but not the ID -> Codeception SwitchToIFrame IFrame Example: <iframe id="iframeToolbar" src="link" frameborder="0" style="position: fixed; left: 0px; top: 0px; z-index: 998; width: 940px;" scrolling="no" width="100px" height="100%"></iframe> Codeception Example: <?php # switch to iframe $I->switchToIFrame("another_frame"); # switch to parent page $I->switchToIFrame(); Is it maybe a Codeception <

How and where should I use the keyword “use” in php

限于喜欢 提交于 2019-12-22 10:38:21
问题 I used use the keyword "use" generally above the class definition. Like this: <?php namespace suites\plugins\content\agpaypal; use \Codeception\Util\Fixtures; use \Codeception\Verify; use \Codeception\Specify; class agpaypalTest extends \Codeception\Test\Unit { protected $tester; ... But now I realised, that I have to put the line for the trait Specify into the class definition. Like this: <?php namespace suites\plugins\content\agpaypal; use \Codeception\Util\Fixtures; use \Codeception\Verify

Run custom code after Codeception suite has finished

南楼画角 提交于 2019-12-21 13:06:28
问题 I am aware of the _bootstrap.php file that's used to set up the testing enviroment, etc., but I'm looking for a way to run some code after the entire test suite has finished. Note that I'm not looking for a way to run code after a single class, i.e. something like _after , but after all classes. Is there a way to achieve this? 回答1: Actually managed to solve this myself, here's how, if anyone is interested. I created a new helper class inside _support. <?php class DataHelper extends

Setup testing database for acceptance tests in Codeception (Laravel)

心已入冬 提交于 2019-12-21 06:06:33
问题 I'm using Codeception framework to perform acceptance tests in Laravel 5 application. I wanted to use a separate database for testing to keep real database from changing through testing. I configued the .yml files based on Codeception documentation. But the real database gets affected anyway. This is my configuration files: /codeception.yml actor: Tester paths: tests: tests log: tests/_output data: tests/_data support: tests/_support envs: tests/_envs settings: bootstrap: _bootstrap.php