Codeception\Extension\RunProcess not starting processes - php

PROBLEM:
Yesterday Codeception introduced new extension which should help with starting/stopping Selenium Server, Chrome Driver, etc (more here). However, even it shows that processes are starting - they're actually not.
acceptance.suite.yml
class_name: AcceptanceTester
modules:
enabled:
- WebDriver:
url: http://127.0.0.1:8080/
browser: chrome
- Yii2:
part: orm
entryScript: index-test.php
cleanup: false
extensions:
enabled:
- Codeception\Extension\RunProcess:
- java -jar /home/tajgeer/.executables/bin/selenium-server.jar
- php /home/tajgeer/Repozytoria/Yii2/yii serve
output:
Acceptance Tests (5)
[RunProcess] Starting java -jar /home/tajgeer/.executables/bin/selenium-server.jar
[RunProcess] Starting php /home/tajgeer/Repozytoria/Yii2/yii serve
E AboutCest: Ensure that about works
E ContactCest: Ensure that contact page works
E ContactCest: Contact form can be submitted
E HomeCest: Ensure that home page works
E LoginCest: Ensure that login works
[RunProcess] Stopping php /home/tajgeer/Repozytoria/Yii2/yii serve
[RunProcess] Stopping java -jar /home/tajgeer/.executables/bin/selenium-server.jar
example error:
[ConnectionException] Can't connect to Webdriver at http://127.0.0.1:4444/wd/hub. Please make sure that Selenium Server or PhantomJS is running.
I've already tried to set o+x permissions on both execs - didn't change anything. When I'm trying to run both tools by using entered commands - everything works well.
Could anyone point out what am I doing wrong?

SOLUTION:
Actually... I've solved it on my own. I've forgot about sleep (processes didn't even had a chance to run as tests were very quick). I've changed acceptance.suite.xml to following:
class_name: AcceptanceTester
modules:
enabled:
- WebDriver:
url: http://127.0.0.1:8080/
browser: chrome
- Yii2:
part: orm
entryScript: index-test.php
cleanup: false
extensions:
enabled:
- Codeception\Extension\RunProcess:
0: java -jar /home/tajgeer/.executables/bin/selenium-server.jar
1: php /home/tajgeer/Repozytoria/Yii2/yii serve
sleep: 5

Related

Codeception Acceptance Tests not working

everyone!
I have been trying to configure Codeception 2.3.6 with Laravel 5.3.30 running on PHP 7.0.23 powered by WAMP 3.1.0. My functional test cases are running fine, but when I try to run my acceptance test cases, a new chrome window opens and then closes without doing anything.
The output in the HTML Report is Codeception Results OK(0s), while the output on the command line is:
WelcomeCept: Perform actions and see result (0.00s)
Time: 3.24 seconds, Memory: 22.75MB
OK (1 test, 0 assertions)
HTML report generated in file://D:\wamp\www\myApp\tests/_output\report.html
First I start ChromeDriver with the command
chromedriver --url-base=/wd/hub
Then I start Selenium Standalone Server 3.13.0 with the command:
java -Dwebdriver.chrome.driver="chromedriver" -jar selenium-server-standalone-3.13.0.jar -port 4445
Then I run my acceptance test suite which contains a single test file, with the command:
call vendor/bin/codecept run acceptance --html
My acceptance.suite.yml is:
class_name: AcceptanceTester
modules:
enabled:
- WebDriver:
url: http://lcms.com/
window_size: false # disabled in ChromeDriver
port: 9515
browser: 'chrome'
restart: true
wait: 200
capabilities:
unexpectedAlertBehaviour: 'accept'
webStorageEnabled: true
javascriptEnabled: true
- Laravel5:
part: ORM
cleanup: false # can't wrap into transaction
environment_file: .env
- \Helper\Acceptance
My WelcomeCept.php file, just for testing the configuration, is:
<?php
class WelcomeCept
{
public function welcomeTest(AcceptanceTester $I)
{
$I->wantTo('perform actions and see result');
}
}
Please review my workflow and let me know if I'm doing things incorrectly or am missing something.
Thanks!
Update: Same thing is happening using GeckoDriver or PhantomJS in WebDriver mode. The tests are passing with OK but not performing any actions.
Solved! I tried WelcomeCest instead of WelcomeCept and things have fallen into place.

Firefox 50 and Selenium 3.0 not working via Codeception tests

My acceptance tests were working, then I upgraded Firefox, and now they don't. I was using Firefox 46 and Selenium 2.53. Now I'm getting the following error:
"The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases"
The issue is, everything I've found talks about setting the system property, through what I assume, is Java. Codeception is PHP. Has anyone else encountered this and how did you resolve it?
In my acceptance.suite.yml file I added the marionette: false line, which does actually trigger Firefox to open (it won't open otherwise), but nothing happens afterward.
class_name: AcceptanceTester
modules:
enabled:
- \Helper\Acceptance
- WebDriver:
browser: firefox
url: https://www.myexample.com/
capabilities:
marionette: false
This error is not about Codeception configuration, but about the way you start Selenium.
You have to pass a correct path to geckodriver as a parameter.
java -jar -Dwebdriver.gecko.driver=~/geckodriver ~/selenium-server-standalone-x.xx.x.jar
In Selenium 2 -D parameters could be given after jar file. Selenium 3 is stricter and parameters must be given before jar file.

Test multiple urls (files) with codeception and log separate results

I'm trying to create a small test suite for a homework assignment, using Codeception. My idea is to apply a single Cest test scenario to multiple URLs and get the different results, which I can then log by some identification (for example name of the file).
There are two main things I can't figure out:
How to run a single test with different URL and log failed assertions/passed assertions for every test?
How to check every assertion, even if some of them fail?
First part:
I assume you are using Codeception with Selenium.
You can configure this in acceptance.suite.yml:
class_name: AcceptanceTester
modules:
enabled:
- WebDriver
- AcceptanceHelper
config:
WebDriver:
url: 'http://localhost.dev:8000/'
browser: 'firefox'
env:
url1:
modules:
config:
WebDriver:
url: 'http://url-1.dev/'
browser: 'chrome'
url2:
modules:
config:
WebDriver:
url: 'http://url-2.dev/'
browser: 'chrome'
url3:
modules:
config:
WebDriver:
url: 'http://url-3.dev/'
browser: 'chrome'
Then invoke the tests like this:
$ php codecept.phar run acceptance --env url1 --env url2 --env url3
For more details: http://codeception.com/docs/07-AdvancedUsage#Environments
Second part:
If an assertion fails, testing still continues with the subsequent environments. You can also use conditional assertions (those that start with canSee and cantSee), which will allow the test to continue even if the assertion fails.
For more details: http://codeception.com/docs/03-AcceptanceTests#Conditional-Assertions

Codeception + Selenium server- browser (chrome) pops up, but web page is always white

Using the latest Codeception.
Tried selenium server 2.40.0 and 2.42.2
Snippit of Config:
enabled:
- WebDriver
WebDriver:
url: 'foo'
browser: chrome
I have chrome web driver in my path.
From cmd line, I kick off the selenium server
java -jar C:\...\vendor\selenium\selenium-server-standalone-2.42.2.jar
From cmd line2,
run acceptance fooCept.php
Chrome opens, but the page is always blank. If I was only running one step, I remember not being able to see anything on the page because it was too quick. But with my latest go around with Codeception, I cannot get to see the web page when I over 30 steps.
Your config syntax is not correct. Try this in acceptance.suite.yml:
modules:
enabled:
- WebDriver
config:
WebDriver:
url: 'http://your.site.dev'
browser: 'chrome'
PHPBrowser was also enabled in the acceptance.suite.yml. Once I removed this, it worked.

Webception / webdriver / ftp

I use Codeception with webdriver and use command line to start tests. I try to use webception to show it on a web-application for my colleagues so I deployed webception on my FTP but i have problems with piloting selenium. I didnt succeed to run the test from my ftp with webcept.
[WebDriverCurlException]
Curl error thrown for http POST to http://127.0.0.1:4444/wd/hub/session with params: {"desiredCapabilities":{"unexpectedAlertBehaviour":"accept","browserName":"firefox"}}
couldn't connect to host
Here is my acceptance.suit.yml :
class_name: WebGuy
modules:
enabled:
#- PhpBrowser
- WebHelper
- REST
- WebDriver
config:
REST:
url: 'http://theAddress/'
timeout: 90
PhpBrowser:
url: 'http://theAddress/'
curl:
CURLOPT_RETURNTRANSFER: true
CURLOPT_FOLLOWLOCATION: true
WebDriver:
url: 'http://theAddress/'
browser: firefox
capabilities:
unexpectedAlertBehaviour: 'accept'
Any suggestions will be welcome. thank you
Try to run Selenium manually. Download Selenium Server here Selenium Downloads , then in the command line, navigate to the folder where the file has been downloaded and type:
java -jar selenium-server-standalone-W.XY.Z.jar
Now, Selenium should be running on the 4444 port. After that, try to run your test again.

Categories