using symfony/panther headless with geckodriver on windows - windows

Im trying to test my Symfony app with panther im on a Windows computer with only Firefox or Edge as Web Browser I cannot install Chrome. I installed the bundle symfony/panther. I downloaded the geckodriver script from this link:
https://github.com/mozilla/geckodriver/releases/tag/v0.31.0
and put it in my project root dir in a folder named drivers.
namespace App\Tests\Controller;
use Symfony\Component\Panther\Client;
use Symfony\Component\Panther\PantherTestCase;
class AccueilControllerTest extends PantherTestCase
{
public function testAccueilController(){
$client = Client::createFirefoxClient();
$client->request('GET', 'http://localhost:8080/');
$client->takeScreenshot('accueil.png');
sleep(5);
}
}
I have set the env variable PANTHER_NO_HEADLESS=1 in the .env.test file
and when I launch my test I have this error :
There was 1 error:
1) App\Tests\Controller\AccueilControllerTest::testAccueilController
Facebook\WebDriver\Exception\InvalidArgumentException: binary is not a Firefox executable
....\vendor\php-webdriver\webdriver\lib\Exception\WebDriverException.php:99
....\vendor\php-webdriver\webdriver\lib\Remote\HttpCommandExecutor.php:372
....\vendor\php-webdriver\webdriver\lib\Remote\RemoteWebDriver.php:131
....\vendor\symfony\panther\src\ProcessManager\FirefoxManager.php:70
....\vendor\symfony\panther\src\Client.php:120
....\vendor\symfony\panther\src\Client.php:524
....\vendor\symfony\panther\src\Client.php:276
....\tests\App\Tests\Controller\AccueilControllerTest.php:19
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

Related

Protractor & selenium server - how to download file in chrome and check if it was downloaded

I want to run tests using protractor via selenium server on another machine with diff ip address. For that I'm using seleniumAddress url. The problem which I see is how to check that after click on "Download" button in chrome browser file was downloaded, for now it won't work although if do that without selenium server it's working fine using
prefs: {
'download': {
'prompt_for_download': false,
'default_directory': './tmp'
}
}

PhantomJS can't find jasmine fixture

In Jasmine I am adding a fixture as below:
jasmine.getFixtures().fixturesPath = '/';
var fixture = readFixtures('test2.html');
setFixtures(fixture);
The tests run fine in the browser.
However, when I try to run the tests using PhantomJS I get the following error:
Network - Resource request error: QNetworkReply::NetworkError(ContentNotFoundError) ( "Error opening /test2.html: No such file or directory" ) URL: "file:///test2.html?_=123456789
It's as if PhantomJS cannot read the correct relative file path.
Is there anything I can do differently to get past this error?
For anyone else running into this, the trick is to call the actual url as opposed to a file, so instead of
$ phantomjs myTest.js path/to/my/SpecRunner.html
try:
$ phantomjs myTest.js http://localhost/path/to/mySpecRunner.html

How do I run my selenium ruby scripts on different browsers?

I have written my script specifically for FF. Now I wish to run that same script on Chrome as well as IE. Also I want to run my tests in following order :
Open browser1.
Run script on that browser.
Close browser1.
Open browser2.
Run script on that browser.
Close browser2.
Please help.
In order to run your tests on :
1.Chrome : you will need to install latest Chrome driver, unzip it and paste its path in the environment variables.
2.IE : you will need to install IEDriver server unzip it and paste its path in the environment variables and enable protected mode for each zone in following way (Internet options->security tab->enable protected mode checkbox).
For running your tests as per the way you mentioned, not sure what framework you're using or whatever, but you can do this with a loop. You can do the following :
def all_browsers
browsers = [:firefox,:chrome,:ie].each do |br|
$driver = Selenium::WebDriver.for br
$driver.manage.window.maximize
$driver.navigate.to("http://google.com")
end
$driver.quit
end

CakePhp 2.4 "Error: Shell class HelloShell could not be found." Paths mess?

I have found several answers on that topic, but none did help me.
So here is the situation. I work on a ubuntu system and my default cakephp 2.4.4 installation is under:
/var/www/myproject/
/gkm-be (this is my app)
/lib/Cake
So all paths here are default and the gkm_be app in general is working smoothly.
In my .bashrc I have the following setting:
PATH=$PATH:$HOME/bin
export PATH="$PATH:/var/www/myproject/lib/Cake/Console/"
When I open a new shell and go to the directory /var/www/myproject/gkm-be and type
Console/cake
I get the error
bash: Console/cake: File or directory not found
after
cd /var/www/myproject/gkm-be/Console/
if I enter cake then I get the core cake with following output
Welcome to CakePHP v2.4.4 Console
---------------------------------------------------------------
App : Console
Path: /var/www/myproject/gkm-be/Console/
---------------------------------------------------------------
Current Paths:
-app: Console
-working: /var/www/myproject/gkm-be/Console
-root: /var/www/myproject/gkm-be
-core: /var/www/myproject/lib
Changing Paths:
Your working path should be the same as your application path. To change your path use the '-app' param.
Example: -app relative/path/to/myapp or -app /absolute/path/to/myapp
Available Shells:
[CORE] acl, api, bake, command_list, console, i18n, schema, server, test, testsuite, upgrade
Note the paths for -app and -working
Not to mention of course that my HelloShell located under
/var/www/myproject/gkm-be/Console/Command/HelloShell.php
is neither listed nor can be called.
Were did I set a path wrong? Can anybody spot the mistake?
Calamity Jane
PS: The code from the shell:
class HelloShell extends AppShell
{
public function main()
{
date_default_timezone_set('Europe/Berlin');
$this->out('Hello world.');
}
}
go to /var/www/myproject/gkm-be and run the command
../lib/Cake/Console/cake Hello

Zend OSX, and a "." added to context path

I downloaded and unpacked the latest version of Zend Framework, onto OSX (10.6) (am also running webserver with XAMPP, but I added the include_path change to both XAMPP and OSX path, but this is all command line so I dont think the php compiler is using the XAMPP install)
I try to create a project and get the following: (note that i am replacing part of the path with "----" just for the purpose of privacy)
sh-3.2# zf create project
testProject
Fatal error: Uncaught exception
'Zend_Exception' with message 'File "Zend/Tool/Project/Context/Zf/./AbstractClassFile.php" does not exist or class "Zend_Tool_Project_Context_Zf_._AbstractClassFile" was not found in the file' in /Volumes/----/----/z/library/Zend/Loader.php:99 Stack trace:
0 /Volumes/----/----/z/library/Zend/Tool/Project/Context/Repository.php(88):
Zend_Loader::loadClass('Zend_Tool_Proje...')
1 /Volumes/----/----/z/library/Zend/Tool/Project/Context/Repository.php(79):
Zend_Tool_Project_Context_Repository->addContextClass('Zend_Tool_Proje...')
2 /Volumes/----/----/z/library/Zend/Tool/Project/Provider/Abstract.php(87):
Zend_Tool_Project_Context_Repository->addContextsFromDirectory('/Volumes/----/...',
'Zend_Tool_Proje...')
3 /Volumes/----/----/z/library/Zend/Tool/Framework/Provider/Repository.php(187):
Zend_Tool_Project_Provider_Abstract->initialize()
4 /Volumes/----/----/z/library/Zend/Tool/Framework/Client/Abstract.php(128):
Zend_Tool_F in
/Volumes/----/----/z/library/Zend/Loader.php
on line 99 sh-3.2#
Note the period after "Context_Zf_"
I've narrowed it down to this block of code:
File: /Volumes/----/----/z/library/Zend/Tool/Project/Provider/Abstract.php
public function initialize()
{
// initialize the ZF Contexts (only once per php request)
if (!self::$_isInitialized) {
// load all base contexts ONCE
$contextRegistry = Zend_Tool_Project_Context_Repository::getInstance();
$contextRegistry->addContextsFromDirectory(
dirname(dirname(__FILE__)) . '/Context/Zf/', 'Zend_Tool_Project_Context_Zf_'
);
$contextRegistry->addContextsFromDirectory(
dirname(dirname(__FILE__)) . '/Context/Filesystem/', 'Zend_Tool_Project_Context_Filesystem_'
);
// determine if there are project specfic providers ONCE
Specifically "dirname(dirname(FILE))" is echoing as "."
if I wrap the block with an 'if (dirname(dirname(__FILE))!=".") { … } ', then I don't get that error, but I get another:
sh-3.2# zf create project testProject
An Error Has Occurred
Context by name applicationDirectory does not exist in the registry.
Zend Framework Command Line Console
Tool v1.11.3 Details for action
"Create" and provider "Project"
Project
zf create project path name-of-profile file-of-profile
I tested on my Mac and it works fine. Have you tried to restart you xampp server, I don't really know how it works as I use Apache & PHP already installed versions not a "AMP pack". Maybe it's a problem with the php.ini include_path which has not been reloaded.
It's clearly a problem with the path as it don't succeed to build the class name :
"Zend/Tool/Project/Context/Zf/./AbstractClassFile.php"
the dot should not appear here.
Can you share you PATH variable from the terminal and your include_path from your php.ini.
Sadly the solution was to install zend server community edition, and have that take care of everything for me. For anyone else on OSX going this route, check out: http://cmorrell.com/webdev/installing-zend-server-zend-framework-on-os-x-291
includes the steps for enabling CLI support.

Resources