Autotests introduction discusses good practices for writing automated tests including using Codeception, Selenium, and Jenkins. It provides an overview of setting up testing environments and executing tests across different browsers and platforms. The document also covers best practices for writing tests such as navigating between pages, comparing actual and expected results, handling asynchronous elements, and using conditionals and loops. Overall, the document is an introduction to automated testing that outlines the tools, frameworks, and methodologies used for writing reliable and maintainable tests.
2. Agenda
● What is good auto QA test
● Codeception
○ Settings - YAML
○ Test code
○ Test organisation
○ Good practices
● Selenium, BrowserStack, PhpBrowser
● Jenkins
● And fun
6. How we can run needed tests?
1. By file name or folder -> ./codecept run tests/acceptance/asap
2. By groups -> ./codecept run -g request -g phones
P.S. in documentation we see -> php codecept run -> ./codecept run do the same
thing
11. Env (environment)
Is used for:
1. Testing host - run tests for prod, stage, or dev
2. Testing platform - run tests for iOS, Windows, Linux; Chrome or Safari
3. Testing resolution - run tests for laptops, full hd or 4K monitors
4. Tests executor - local Selenium, Selenium Grid, BrowserStack or PhpBrowser
5. Tests misc - GIFs of errors, Allure reporting...
12. Running tests for needed env
./codecept run acceptance --env local_asap
13. Combining all
./codecept run acceptance --env local_asap -g request --debug
P.S. --debug option for seeing all steps and additional information, but this make
tests slower
14. Jenkins
Is tool that executes tests (do the job) for you and where you can find test outputs
http://192.168.3.85/view/ASAP
Login: manager
Pass: xxxxxxx701
15. Create Jenkins job
1. Создать Item
2. Copy from -> use most green job name
3. Configure job at “Настройки” -> “Сборка” -> Exec command
4. Edit command where line ./codecept run …
22. How can we get the test subject, if it is not
on current page???
1. Navigate to the page -> $I->amOnPage('/about');
2. Click -> $I->click('#nav a');
3. Fill forms -> $I->fillField('.user[email]','artur@babyuk.com');
4. Ask developers for help
23. What the heck just happened with $I-click()?
It is CSS selector, but there is many options
More info: https://blog.mozilla.org/webqa/2013/09/26/writing-reliable-locators-
for-selenium-and-webdriver-tests/
24. Comparing actual with expected
1. $I->see('Thank you'); $I->dontSee('Please enter email');
2. $I->seeElement('.success'); $I->dontSeeElement('.error');
3. $I->seeInCurrentUrl('/result-page'); $I->dontSeeInCurrentUrl('/oops');
4. Many other helper methods
25. But this is not so simple
There is problems - animation, network, designers and developers…
Some elements can lagg time to time or be not visible, but we need to autotest it
1. $I->wait(10);
2. $I->waitForElementVisible('.success', 10);
3. $I->waitForText('Success, we will contact you shortly', 30);
4. $I->waitForAllScriptsLoaded($I);
5. $I->scrollTo('footer');
26. Sometimes we need only to get data
1. $aLinkText = $I->grabMultiple('a');
2. $aLinks = $I->grabMultiple('a', 'href');
3. $url = $I->grabFromCurrentUrl();
4. $heading = $I->grabTextFrom('h1')
27. There is a lot of needed methods
http://codeception.com/docs/modules/WebDriver#Actions
You can also develop your common methods and put them here:
https://gitlab.dyninno.net/qa-
automation/TravelFrontendSeleniumTestingSystem/blob/master/tests/_support/
WebHelper.php
28. But tests are not so simple, how about
conditions?
https://clevertechie.com/php/5/php-if-else-statement