I have a program i'm writing in perl using Selenium::Remote::Driver that is also using threads.
Is S:R:D not thread friendly? When I start a thread and try to open a selenium driver instance, I would get a random error(dont have on hand, I got past this). For now, I set a shared variable that makes it so only one selenium instance is executing commands at a time, but i'm still running into errors, right now is with setting cookies in the selenium instance.
Is there a way around this?
This is how my program goes for instance:
setup driver
$driver = Selenium::Remote::Driver->new( 'auto_close' => 0,
'browser_name' => 'chrome',
extra_capabilities' => {
'chromeOptions' => {
'args' => ['window-size=1920,1080',
'blink-settings=imagesEnabled=false']}});
Thread 1 Starts
Thread 2 Starts
Thread 2 Randomly won the race of getting selenium started first, does stuff
Thread 1 Waits til thread 2 is done doing selenium commands.
....Fast forward both threads are done setting up....
Thread 1 Wins the race now and starts setting a cookie in theirenter code here selenium instance on a webpage we're on, www.mywebsite.com
$driver->add_cookie("anything", "1", "/", 'www.mywebsite.com','1','1');
this thread ends up terminating because of the error
Thread 1 terminated abnormally: Error while executing command: invalid argument: invalid argument: invalid 'secure' (Session info: chrome=81.0.4044.129) at /Library/Perl/5.18/Selenium/Remote/Driver.pm line 402 thread 1. at /Library/Perl/5.18/Selenium/Remote/Driver.pm line 353 thread 1.
No matter what we change it to, this will still error out, anyone have any ideas? is this really just not thread friendly and i have to try something else?