I'm using Capybara::Selenium from my script (not tests) for getting some image from external site. Page loads fine, all images are loaded also and I see them, but any attempt to execute function page.session.driver.evaluate_script always throws Net::ReadTimeout: Net::ReadTimeout with #<TCPSocket:(closed)>.
Full code:
require 'capybara-webkit'
require 'selenium-webdriver'
JS_GET_IMAGE = <<~EJSGETIMAGE
var img = document.getElementById('requestImage');
const cvs = document.createElement('canvas');
cvs.width = img.width;
cvs.height = img.height;
cvs.getContext('2d').drawImage( img, 0, 0 );
return cvs.toDataURL("image/png");
EJSGETIMAGE
session = Capybara::Session.new :selenium
page = session.visit Cfg.site.url
driver = session.driver.browser
driver.manage.timeouts.script_timeout = 5000
@img = driver.execute_async_script JS_GET_IMAGE
Okay, I started to test very simple script, but that also gone to the same error.
page.session.driver.browser.execute_async_script("setTimeout(arguments[0], 2000)")
Also I used session = Capybara::Session.new :selenium_headless and got the same error.
- ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
- selenium-webdriver (3.142.3)
- capybara (3.28.0)
- capybara-webkit (1.15.1)
- community/geckodriver 0.24.0-1
- firefox 68.0.1 (64-битный)
Any help is very appreciated.