tester3
tester3

Reputation: 423

Problem running Selenium with Firefox, Geckodriver and Perl

I've got a problem running Selenium with Perl's Selenium::Remote::Driver.

I'm on Ubuntu 22 with Selenium standalone 3.9.1 + Geckodriver 0.29.0 + Firefox 91.7.0esr

First, I've tried to use the newest versions of all software but there was error too. On the other machine with Centos 7 on it I've got all this software working fine, so I've decided to downgrade everything to the older versions.

I've installed Firefox from sources, downloaded the Selenium 3.9.1 just from my Centos 7 machine (to be sure it's fine) and downloaded the Geckodriver.

I run Selenium server with this command (the geckodriver is in the same folder):

xvfb-run java  -Dwebdriver.gecko.driver=./geckodriver -jar selenium-server-standalone-3.9.1.jar

The server starts normally, but when I try to run my Perl script - it starts and "freezes" at the string where I create a new Selenium::Remote::Driver object.

This is what Selenium writes:

xvfb-run java  -Dwebdriver.gecko.driver=./geckodriver -jar selenium-server-standalone-3.9.1.jar

21:01:29.989 INFO - Selenium build info: version: '3.9.1', revision: '63f7b50'
21:01:29.990 INFO - Launching a standalone Selenium Server on port 4444
2022-12-10 21:01:30.614:INFO::main: Logging initialized @1317ms to org.seleniumhq.jetty9.util.log.StdErrLog
2022-12-10 21:01:30.916:INFO:osjs.Server:main: jetty-9.4.7.v20170914, build timestamp: 2017-11-21T21:27:37Z, git hash: 82b8fb23f757335bb3329d540ce37a2a2615f0a8
2022-12-10 21:01:30.967:WARN:osjs.SecurityHandler:main: [email protected]@76508ed1{/,null,STARTING} has uncovered http methods for path: /
2022-12-10 21:01:30.974:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@76508ed1{/,null,AVAILABLE}
2022-12-10 21:01:31.050:INFO:osjs.AbstractConnector:main: Started ServerConnector@94c87b{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2022-12-10 21:01:31.051:INFO:osjs.Server:main: Started @1754ms
21:01:31.051 INFO - Selenium Server is up and running on port 4444
2022-12-10 21:01:43.601:INFO:osjshC.ROOT:qtp770189387-11: org.openqa.selenium.remote.server.WebDriverServlet-7f1302d6: Initialising WebDriverServlet
21:01:43.741 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.Status@18d81100
21:01:43.750 INFO - /status: Executing GET on /status (handler: Status)
21:01:43.779 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession@7dd86e24
21:01:43.789 INFO - /session: Executing POST on /session (handler: BeginSession)
21:01:43.899 INFO - Capabilities are: Capabilities {acceptSslCerts: true, browserName: firefox, javascriptEnabled: true, version: }
21:01:43.900 INFO - Capabilities {acceptSslCerts: true, browserName: firefox, javascriptEnabled: true, version: } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.firefox.GeckoDriverService)
1670706103980   geckodriver     INFO    Listening on 127.0.0.1:16612
1670706104621   mozrunner::runner       INFO    Running command: "/usr/bin/firefox" "--marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofileRTGbtt"
[GFX1-]: glxtest: libEGL missing
1670706106386   Marionette      INFO    Marionette enabled
console.warn: SearchSettings: "get: No settings file exists, new profile?" (new NotFoundError("Could not open the file at /tmp/rust_mozprofileRTGbtt/search.json.mozlz4", (void 0)))
1670706150816   Marionette      INFO    Listening on port 36747
Exiting due to channel error.
Exiting due to channel error.
Exiting due to channel error.
21:02:45.425 INFO - HTTP Status: '500' -> incorrect JSON status mapping for 'timeout' (408 expected)

Update: The part of my Perl script, it freezes at the string "my $driver = Selenium::Remote::Driver->new;"

#!/usr/bin/perl

use strict;
use warnings;

use utf8;

use DBI;
use Selenium::Remote::Driver;
use Data::Dumper;

binmode STDOUT, ":utf8";

print "Started parser at ".scalar(localtime)."\n\n";

my $dbh = DBI->connect("DBI:mysql:db", "user", "pass", {mysql_enable_utf8 => 1});

my $total_words = 0;

exit if !$ARGV[0];

my @dictionary = @ARGV;

print "Initial hashtag(s): ".join(" ", @dictionary)."\n\n";

my $driver = Selenium::Remote::Driver->new;

$driver->set_window_position(0, 0);
$driver->set_window_size(20000, 600, 'current');

......

Update 2: I've installed the Firefox 108 from source, downloaded geckodriver 0.32.0 and selenium 4.7.1 as @HåkonHægland have suggested. But still it's not working.

Here are the outputs: This is the output when I try to run the Perl script:

Could not create new session: Server returned error message read timeout at /usr/share/perl5/Net/HTTP/Methods.pm line 274.

This is the output of Selenium-server when I try to run the script:

17:36:55.676 WARN [SeleniumSpanExporter$1.lambda$export$3] - {"traceId": "8206aa152f3c4da7260f4378969b94f1","eventTime": 1670953004537922002,"eventName": "exception","attributes": {"driver.url": "http:\u002f\u002flocalhost:13123","exception.message": "Error while creating session with the driver service. Stopping driver service: java.util.concurrent.TimeoutException\nBuild info: version: '4.7.1', revision: 'c6795baf1a3'\nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-1026-aws', java.version: '11.0.17'\nDriver info: driver.version: unknown","exception.stacktrace": "org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException\nBuild info: version: '4.7.1', revision: 'c6795baf1a3'\nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-1026-aws', java.version: '11.0.17'\nDriver info: driver.version: unknown\n\tat org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:65)\n\tat org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)\n\tat org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)\n\tat org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)\n\tat org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)\n\tat org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)\n\tat org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:99)\n\tat org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55)\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:124)\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:106)\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)\n\tat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:146)\n\tat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:69)\n\tat org.openqa.selenium.grid.node.local.SessionSlot.apply(SessionSlot.java:147)\n\tat org.openqa.selenium.grid.node.local.LocalNode.newSession(LocalNode.java:379)\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession(LocalDistributor.java:645)\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession(LocalDistributor.java:564)\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest(LocalDistributor.java:818)\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1(LocalDistributor.java:779)\n\tat java.base\u002fjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base\u002fjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base\u002fjava.lang.Thread.run(Thread.java:829)\nCaused by: java.util.concurrent.TimeoutException\n\tat java.base\u002fjava.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1886)\n\tat java.base\u002fjava.util.concurrent.CompletableFuture.get(CompletableFuture.java:2021)\n\tat org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:206)\n\tat org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:59)\n\t... 21 more\n","exception.type": "org.openqa.selenium.TimeoutException","logger": "org.openqa.selenium.grid.node.config.DriverServiceSessionFactory","session.capabilities": "{\"acceptSslCerts\": true,\"browserName\": \"firefox\",\"javascriptEnabled\": true,\"platformName\": \"ANY\",\"version\": \"\",\"platform\": \"ANY\"}\n"}}

Upvotes: 1

Views: 545

Answers (1)

tester3
tester3

Reputation: 423

The solution was very unexpected for me - I've been using AWS EC2 and after I've increased CPU and RAM - everything started working correctly!

Upvotes: 1

Related Questions