I have recently written a lot of selenium 1 tests for a fairly complex project. They are all written in php and run smoothly on the selenium-server 1.0.7.
Obviously with firefox 5 (and 6 released today) selenium server 1.0.7 is not working anymore. I've tried, but the server is just opening blank windows.
Now I am trying to get those tests running on selenium grid. I managed to get a hub and a couple of remote-controls runnnig using grid v1, but they only open blank windows just like the old server did. So I figured i needed to upgrade to grid v2.
For some reason i can get the clients connected to the hub, but if I try running my tests against the hub it doesn't seem to be able to connect at all ("PHPUnit_Framework_Exception: Could not connect to the Selenium RC server"). I tried running them against selenium standalone server 2.4.0 and that does seem to work.
I read in a forum, that selenium grid 2 just doesn't work with phpunit (yet?).
How can i get my tests running on a grid? What is missing for phpunit to connect to the server? I appreciate any help!
I set up the hub as follows:
java -jar selenium-server-standalone-2.4.0.jar -role hub
And two slaves:
java -jar selenium-server-standalone-2.4.0.jar -role rc -hub http://127.0.0.1:4444/grid/register -port 5555
java -jar selenium-server-standalone-2.4.0.jar -role webdriver -hub http://127.0.0.1:4444/grid/register -port 5556
Everything seems to be working till here as i see two nodes in the grid console (http://localhost:4444/grid/console).
So here is all the initialization I am doing in code:
<?php
require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
class Grid_Test extends PHPUnit_Extensions_SeleniumTestCase
{
public $captureScreenshotOnFailure = false;
public static $browsers = array(
'FFLinux' => array(
'name' => 'Firefox on Linux',
'browser' => '*firefox',
'host' => '127.0.0.1',
'port' => 4444,
'timeout' => 30000
));
public function setUp()
{
$this->setBrowserUrl('http://www.google.com');
}
public function testGridWorking()
{
$this->open('/');
$this->assertTrue(false);
}
}
This code still works on the standalone server 2.4.0. It fails at the last line as expected.
The Exception seems to be thrown in PHPUnit/Extentions/SeleniumTestCase/Driver.php. There seems to be the problem.
protected function doCommand($command, array $arguments = array())
{
$url = sprintf(
'http://%s:%s/selenium-server/driver/?cmd=%s',
$this->host,
$this->port,
urlencode($command)
);
[...]
$handle = #fopen($url, 'r', FALSE, $context);
if (!$handle) {
throw new PHPUnit_Framework_Exception(
'Could not connect to the Selenium RC server.'
);
}
[...]
}
When i request http://localhost:4444/selenium-driver/driver in the browser, i get:
HTTP ERROR: 500
org.openqa.grid.internal.GridException: Session not available - []
RequestURI=/selenium-server/driver
Any idea how to fix this? Do I need to change that url maybe ?
Also make sure you have setup the Grid correctly here is a small post that shows how it is done : http://opensourcetester.co.uk/2011/07/06/selenium-grid-2/
BTW I dint see code that does the driver instantiation.. Am i missing something?
Here is how it is done:
require_once "phpwebdriver/WebDriver.php";
require("phpwebdriver/LocatorStrategy.php");
$webdriver = new WebDriver("localhost", "4444");
$webdriver->connect("firefox");
$webdriver->get("http://google.com");
$element = $webdriver->findElementBy(LocatorStrategy::name, "q");
$element->sendKeys(array("selenium google code" ) );
$element->submit();
$webdriver->close();
for more: http://code.google.com/p/php-webdriver-bindings/
The problem with trying to use PHPUnit with Selenium Grid 2 has already been reported to the project owners. Have a look at the patch available here to see if it works for you.
Anyway, if I were you I would start thinking about migrating to WebDriver through one of the drivers available out there for PHP, like php-webdriver.
Related
I am developing an app in Laravel Framework 5.7.13.
I have a class called
<?php
namespace App\Library;
class Crypto{
private $cipher;
private $cstrong;
private $keylen;
private $key;
public function __Crypto(){
$this->cipher= Config::get('cipher');
$this->cstrong = true;
$this->keylen = 5;
$this->key = bin2hex(openssl_random_pseudo_bytes($keylen, $cstrong));
}
public function opensslEncrypt($value){
$ivlen = openssl_cipher_iv_length($this->cipher);
$iv = openssl_random_pseudo_bytes($ivlen);
$ciphertext_raw = openssl_encrypt($value, $this->cipher, $this->key, $options=OPENSSL_RAW_DATA, $iv);
$hmac = hash_hmac('sha256', $ciphertext_raw, $this->key, $as_binary=true);
$ciphertext = base64_encode( $iv.$hmac.$ciphertext_raw );
return $ciphertext ;
}
}
Now in my controller I did:
$crypto = new Crypto();
$encryptedValue = $crypto->opensslEncrypt($orderId);
In my Config\app.php
'cipher' => 'AES-256-CBC'
But when I run my app, I get
ErrorException (E_WARNING)
openssl_cipher_iv_length(): Unknown cipher algorithm
How to resolve this?
I tried to comment the cipher line in the Config\app.php, but then it gave some other errors.
Please help...
I ran into a similar problem with Laravel 5.7.13.
My error with Laravel and the openssl_cipher_iv_length() function was encountered when I updated my WampServer installation to PHP v7.2.x (from v7.1.10). Yes, I am running on Windows.
Switching back to php v7.1.10 would clear the error.
To solve my error with openssl_cipher_iv_length(), I compared the php.ini files from the two php versions. When comparing the files I noticed that I did not have the extension_dir set properly. This was my main issue, but there were other edits I made in the past that I also incorporated into the new PHP environment (i.e. extensions that were enabled and XDEBUG settings).
Also... I did notice that the extension names were previously defined as:
extension=php_<ext>.dll
or
extension=<ext>.so
and are now using:
extension=<ext>
So my issue with openssl_cipher_iv_length() was a result of the PHP version and not Laravel.
I hope this information helps.
My app starts locally by http : //sm1/app/web/app_dev.php (symfony3).
PHPUnit test has been build by framework.
namespace Tests\AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class GoodControllerTest extends WebTestCase
{
public function testCompleteScenario()
{
// Create a new client to browse the application
$client = static::createClient([], ['HTTP_HOST' => 'sm1']);
// Create a new entry in the database
$crawler = $client->request('GET', '/good/');
$this->assertEquals(200,
$client->getResponse()->getStatusCode(),
"Unexpected HTTP status code for GET /good/"
);
$crawler = $client->click(
$crawler->selectLink('Create a new entry')->link());
But after test running I've got an error
There was 1 error:
1) Tests\AppBundle\Controller\GoodControllerTest::testCompleteScenario
InvalidArgumentException: The current node list is empty.
/home/sm1/www/app/vendor/symfony/symfony/src/Symfony/Component/DomCrawler/Crawler.php:735
/home/sm1/www/app/tests/AppBundle/Controller/GoodControllerTest.php:18
and in a log file this message:
request.INFO: Matched route "{route}".
{"route":"good_index","route_parameters":
{"_controller":"AppBundle\Controller\GoodController::indexAction",
"_route":"good_index"},
"request_uri":"http://sm1/good/","method":"GET"} []
How to fix "request_uri" from "http : //sm1/good/"
to "http : //sm1/app/web/app_dev.php/good/" ?
It is necessary to start web app only by http://app. That is, to use PHPUnit you need a virtual host. If the name of the input script is different from the default, note this in the file .htaccess.
I am trying to use elastic search with java api, but when i try to run application, i am getting following exception.
18:13:52.378 [elasticsearch[Fallen One][generic][T#1]] INFO org.elasticsearch.client.transport - [Fallen One] failed to get local cluster state for [#transport#-1][integra][inet[/127.0.0.1:9300]], disconnecting...
org.elasticsearch.transport.ReceiveTimeoutTransportException: [][inet[/127.0.0.1:9300]][cluster/state] request_id [52] timed out after [5001ms]
at org.elasticsearch.transport.TransportService$TimeoutHandler.run(TransportService.java:356) [elasticsearch-1.0.1.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_51]
at java.lang.Thread.run(Thread.java:744) [na:1.7.0_51]
18:13:52.381 [elasticsearch[Fallen One][generic][T#1]] DEBUG org.elasticsearch.transport.netty - [Fallen One] disconnected from [[#transport#-1][integra][inet[/127.0.0.1:9300]]]
18:13:52.391 [elasticsearch[Fallen One][generic][T#3]] DEBUG org.elasticsearch.transport.netty - [Fallen One] connected to node [[#transport#-1][integra][inet[/127.0.0.1:9300]]]
Code for connecting to elastic search is
private String[] esNodes = { "127.0.0.1:9300" };
protected TransportClient buildClient() throws Exception {
Settings settings = ImmutableSettings.settingsBuilder()
.put("client.transport.sniff", true)
.put("client.transport.ignore_cluster_name",true).build();
TransportClient client = new TransportClient(settings);
for (int i = 0; i < esNodes.length; i++) {
client.addTransportAddress(toAddress(esNodes[i]));
}
return client;
}
private InetSocketTransportAddress toAddress(String address) {
if (address == null) return null;
String[] splitted = address.split(":");
int port = 9300;
if (splitted.length > 1) {
port = Integer.parseInt(splitted[1]);
}
return new InetSocketTransportAddress(splitted[0], port);
}
can any one kindly help me, i am new to elastic search and have no idea how to resolve the issue.
I am using this code to connect to my elasticsearch and its pretty well working.
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", clusterName).build();
this.client = new TransportClient(settings)
.addTransportAddress(new InetSocketTransportAddress(ipAddress,9300));
Where ipAddress and Clustername are argument of my function.
You should have a look at the network on your laptop. Check if you can connect to localhost. Another thing you could try is start two elasticsearch instances with the same configuration to see if they connect. Finally have a look at the network part of elasticsearch.yml. When having network problems on a local machine I usually try the following two options:
network.host: localhost
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["localhost"]
I think Elastic search server is Not started.. Try to hit in browser or curl comments.. If it works.. Try the above code..
NOTE:IF YOUR JAVA API JAR VERSION DIFFERS ALSO LL RAISE PROB.. ( get java api version same as ES version
Note : elasticsearch java api helps you connect to with elasticsearch.. But its can't start a elasticsearch node using api..
Your code is good.. It's Vry standard too..
When I run even a sample test, either in Netbeans IDE of from the command line, e.g.:
class WebTest extends PHPUnit_Extensions_Selenium2TestCase
{
protected function setUp()
{
$this->setBrowser('firefox');
$this->setBrowserUrl('http://www.example.com/');
}
public function testTitle()
{
$this->url('http://www.example.com/');
$this->assertEquals('Example WWW Page', $this->title());
}
}
I get the PHPUnit response, but it doesn't seem to be communication with the Selenium server as no browser window was created.
PHPUnit 3.6.10 by Sebastian Bergmann.
Configuration read from /var/www/gcd/framework/yii/gadget/protected/tests/phpunit.xml
F
Time: 1 second, Memory: 10.50Mb
There was 1 failure:
1) WebTest::testTitle
Failed asserting that null matches expected 'Example WWW Page'.
Using PHPUnit 3.6.10 and selenium-server-standalone-2.21.0
Anyone any ideas?
Turns out, if you run PHPUnit with sudo, it works! Doh!
I recently upgraded to Flash Builder 4.5 for PHP and am trying to upload a release build to my remoteserver. When I try to make a php call from the app, I get the error:
Send failednChannel.Security.Error error Error #2048 url: 'http://localhost/my_php/public/gateway.php'
The release build works fine on my localhost machine. All of my php service calls are on my remote host. Here's the structure of my remote host:
/my_directory/html (this is the root directory)
/my_directory/html/my_php/public/release (this is where my .html wrapper and .swf files sit)
/my_directory/html/my_php/public (this is where my gateway.php and amf_config.ini files sit)
The error specifically references 'localhost', but I can't find where that gets set. When I google error #2048, the solutions point to a badly configured crossdomain file...all my services are on remotehost (where the app is hosted) so I don't think that could be the issue.
Here is my amf_config.ini file:
[zend]
webroot = "/my_directory/html"
zend_path ="/my_directory/html/ZendFramework/library"
library ="/my_directory/html/my_php/library"
services ="/my_directory/html/my_php/services"
[zendamf]
amf.production = false
amf.directories[]=/my_directory/html/my_php/services
Here is my gateway.php file:
<?php
ini_set("display_errors", 1);
$dir = dirname(__FILE__);
$webroot = $_SERVER['DOCUMENT_ROOT'];
$configfile = "$dir/amf_config.ini";
$servicesdir = $dir.'/../services';
$librarydir = $dir.'/../library';
//default zend install directory
$zenddir = $webroot.'/ZendFramework/library';
//Load ini file and locate zend directory
if (file_exists($configfile)) {
$arr = parse_ini_file($configfile, true);
if (isset($arr['zend']['webroot'])) {
$webroot = $arr['zend']['webroot'];
$zenddir = $webroot.'/ZendFramework/library';
}
if (isset($arr['zend']['zend_path'])) {
$zenddir = $arr['zend']['zend_path'];
}
if (isset($arr['zend']['library'])) {
$librarydir = $arr['zend']['library'];
}
if (isset($arr['zend']['services'])) {
$servicesdir = $arr['zend']['services'];
}
}
// Setup include path
// add zend directory, library and services to include path
set_include_path(get_include_path()
.PATH_SEPARATOR.$zenddir
.PATH_SEPARATOR.$librarydir
.PATH_SEPARATOR.$servicesdir);
// Initialize Zend Framework loader
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true)->suppressNotFoundWarnings(true);
// Load configuration
$default_config = new Zend_Config(array("production" => false), true);
$default_config->merge(new Zend_Config_Ini($configfile, 'zendamf'));
$default_config->setReadOnly();
$amf = $default_config->amf;
// Store configuration in the registry
Zend_Registry::set("amf-config", $amf);
// Initialize AMF Server
$server = new Zend_Amf_Server();
$server->setProduction($amf->production);
if (isset($amf->directories)) {
$dirs = $amf->directories->toArray();
foreach ($dirs as $dir) {
if ($dir == "./") {
$server->addDirectory($webroot);
} else
if (realpath("{$webroot}/{$dir}")) {
$server->addDirectory("{$webroot}/{$dir}");
} else
if (realpath($dir)) {
$server->addDirectory(realpath($dir));
}
}
}
// Initialize introspector for non-production
if (! $amf->production) {
$server->setClass('Zend_Amf_Adobe_Introspector', '',
array("config" => $default_config, "server" => $server));
$server->setClass('Zend_Amf_Adobe_DbInspector', '',
array("config" => $default_config, "server" => $server));
}
// Handle request
echo $server->handle();
i had the same problem in a flex - blaze - environment. The real Problem was the context-root in the project properties.
because you used flex 4.5, there is no input field for this setting. in flex builder 3, there was a setting in the project properties -> flex server -> context root.
i gone crazy and found after hours an article on adobes bugs-site [FB-22939].
That solve my problem. I have no idea, wich project settings you are using, try to search a string named {context.root} in your project or post a liite bit more about your project settings. i know blaze is different from php, but maybe it is a tip bringing you back on track.
Unfortunately I'm not able to reproduce my thread and setting up an php environment with more knowledge about your setup. (Server-Technology, and so one)
edit:
additional Info:
I've found a list of all compiler arguments. Try it with this argument:
-context-root <context-path>
full name -compiler.context-root
path to replace {context.root} tokens for service channel endpoints
br
Frank