Saurabh Shrivastava
Saurabh Shrivastava

Reputation: 1484

Error while using Selenium::Remote::Driver

I am trying to use Perl with the Selenium::Remote::Driver module.

My code:

use Selenium::Remote::Driver;
my $driver = Selenium::Remote::Driver->new('browser_name' => 'internet explorer',
                                           'port'         => '5555',
                                           'auto_close'   => 0);
$driver->get('http://www.google.com');
print $driver->get_title();
$driver->quit();

I am getting this error:

Could not connect to SeleniumWebDriver: Can't use string ("Command not found: GE
T /wd/hub/s"...) as a HASH ref while "strict refs" in use at C:/Perl/site/lib/Se
lenium/Remote/ErrorHandler.pm line 125.
 at C:/Perl/site/lib/Selenium/Remote/RemoteConnection.pm line 42.

Any idea how to fix it?

Upvotes: 0

Views: 237

Answers (1)

Alex
Alex

Reputation: 225

To user who use Perl package Selenium::Remote::Driver this package is not compatible w/ hub mode. But you could easily make it work like this: open the file perl_root/Selenium/Remote/Commands.pm and for each url attribute in the hash returned for example for this line :

'status' => {
            'method'             => 'GET',
            'url'                => 'status',
            'no_content_success' => 0
        },

Modify it with :

'status' => {
            'method'             => 'GET',
            'url'                => 'wd/hub/status',
            'no_content_success' => 0
        },

That's all now you understand how it work, you could modify the Driver.pm (or Commands.pm) file and for example change the method _execute_command to change the way to handle commands : if we are in hub or not... by making a constant or anything you prefer (new object attribute, environment variable...) but you cannot use hub mode with this Perl package without modification.

regards,

Upvotes: 1

Related Questions