Reputation: 113
I navigated to google and called the get_current_url() method. but it's showing timeout and exiting the program.
Here is the code I tried
my $driver = Selenium::Remote::Driver->new(
'browser_name' => 'firefox',
'platform' => 'Windows',
'extra_capabilities' => {
'moz:firefoxOptions' => {},
}
);
$driver->debug_on() ;
$driver->get("https://www.google.com/");
wait_until {print $driver->get_path()};
$driver->quit;
I've turned on debug and got the following output in console
Prepping get
Executing get
REQ: POST, http://localhost:4444/wd/hub/session/69ced133-9420-4b0e-a7fd-e4f6bb343f7e/url, {"url":"https://www.google.co.in/"}
RES: {"value":null}
Prepping getCurrentUrl
Executing getCurrentUrl
REQ: GET, http://localhost:4444/wd/hub/session/69ced133-9420-4b0e-a7fd-e4f6bb343f7e/url, {}
RES: read timeout at C:/Perl64/lib/Net/HTTP/Methods.pm line 268.
Error while executing command: Server returned error message read timeout at C:/Perl64/lib/Net/HTTP/Methods.pm line 268.
instead of data at C:/Perl64/site/lib/Selenium/Remote/Driver.pm line 403.
at C:/Perl64/site/lib/Selenium/Remote/Driver.pm line 353.
Prepping quit
Executing quit
REQ: DELETE, http://localhost:4444/wd/hub/session/69ced133-9420-4b0e-a7fd-e4f6bb343f7e, {}
In console,program stucks here for while- 'Executing getCurrentURL' and later shown up with timeout message-Res:read timeout
Upvotes: 1
Views: 307
Reputation: 40778
The following works for me using Windows 10, Strawberry Perl version 5.30.1.
I installed geckodriver.exe
from
https://github.com/mozilla/geckodriver/releases
and Selenium Server from
https://www.selenium.dev/downloads/
then downloaded firefox
binary from
https://www.mozilla.org/en-US/firefox/new/
and then started the server successfully from the command prompt:
> java "-Dwebdriver.gecko.driver=geckodriver/geckodriver.exe" -jar selenium-server/selenium-server-standalone-3.141.59.jar -host localhost -port 4444
20:00:48.591 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
20:00:53.896 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
2020-07-06 20:00:54.601:INFO::main: Logging initialized @12170ms to org.seleniumhq.jetty9.util.log.StdErrLog
20:01:05.928 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
20:01:23.567 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
Now the following Perl script works:
use feature qw(say);
use strict;
use warnings;
use Selenium::Remote::Driver;
my $driver = Selenium::Remote::Driver->new(
remote_server_addr => "127.0.0.1"
);
$driver->get('http://www.google.com');
say "Result: ", $driver->get_title();
$driver->quit();
Output:
Result: Google
Note: using localhost
instead of 127.0.0.1
for remote_server_addr
does not work for some reason, see this question for more information.
Upvotes: 1