I use stones headlessand selenium-webdriverto activate the browser without the Firefox browser:
headless = Headless.new(
video: {
frame_rate: 12,
codec: 'libx264'
}
)
headless.start
driver = Selenium::WebDriver.for(:firefox)
With this code, I can write the following:
driver.navigate.to("http://google.com")
However, the following message causes an error after visiting "/" in the browser:
get '/' do
driver.navigate.to("http://google.com")
erb :root
end
The error is as follows:
*** Errno::ECONNREFUSED Exception: Failed to open TCP connection to 127.0.0.1:7055 (Connection refused - connect(2) for "127.0.0.1" port 7055)
I am sure that this is because it is driver.navigatenot called in the headless area, so it cannot connect to the Firefox instance.
I also tried using the modular style of the sinatra, but the same error occurred.
workaround
, , - script. script loop , . sinatra PTY.spawn stdin stdout, Sinatra. , script ( ), Sinatra. w371 > - i/o.
, , , ( )