Comments (7)
I hope you don't mind @sj26 but I've raised a PR using your code, as I'd like to use it in my own project, and I figured if I was editing the code anyway I might as well raise it as a PR. I've credited you in the commit message. Let me know if you object and I'll close it right away.
FYI I've updated it slightly to use a monotonic clock (rather than CPU time) as suggested in this blog post.
from cuprite.
If I start a process manually it starts fine:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --disable-gpu --hide-scrollbars --mute-audio --enable-automation --disable-web-security --window-size=1024,768 --remote-debugging-port=0 --remote-debugging-address=127.0.0.1
[0118/155835.406981:ERROR:xattr.cc(64)] setxattr org.chromium.crashpad.database.initialized on file /var/folders/sv/kt7w98jx5zj16c4whzrwmx9m0000gn/T/: Operation not permitted (1)
[0118/155835.408449:ERROR:file_io.cc(89)] ReadExactly: expected 8, observed 0
[0118/155835.408905:ERROR:xattr.cc(64)] setxattr org.chromium.crashpad.database.initialized on file /var/folders/sv/kt7w98jx5zj16c4whzrwmx9m0000gn/T/: Operation not permitted (1)
[0118/155835.451772:WARNING:dns_config_service_posix.cc(182)] dns_config has unhandled options!
[0118/155835.452613:ERROR:gpu_process_transport_factory.cc(967)] Lost UI shared context.
DevTools listening on ws://127.0.0.1:50152/devtools/browser/bc758536-c437-49af-8f04-359421e57c5d
I think it's just aborting too early. It looks like it tries to read up to 3 times, but I think the read will return when it encounters a newline, so perhaps it needs to be time based instead of attempt-count based.
from cuprite.
Confirmed, changing attempts
from 3
to 10
gets it working
from cuprite.
Making this based on elapsed cpu time seems sensible. This works well for me:
def parse_ws_url(read_io)
output = ""
start = ::Process.clock_gettime(::Process::CLOCK_PROCESS_CPUTIME_ID)
timeout = start + 1.0
regexp = /DevTools listening on (ws:\/\/.*)/
while (now = ::Process.clock_gettime(::Process::CLOCK_PROCESS_CPUTIME_ID)) < timeout
begin
output += read_io.read_nonblock(512)
rescue IO::WaitReadable
IO.select([read_io], nil, nil, timeout - now)
else
if output.match?(regexp)
@ws_url = Addressable::URI.parse(output.match(regexp)[1])
@host = @ws_url.host
@port = @ws_url.port
break
end
end
end
unless @ws_url
raise "Chrome process did not produce websocket url within 1 second"
end
end
from cuprite.
I decided to drop everything Chrome produces, didn't find anything important there except ws_url.
I like your solution, do you want to open a PR?
from cuprite.
For what it's worth I'm seeing this as well. Both solutions (increasing attempts to 10 and @sj26 's while loop) work on my project.
from cuprite.
Closing this after merging #24
from cuprite.
Related Issues (20)
- ReferenceError: _cuprite is not defined HOT 7
- Cuprite.scrollIntoViewport does not properly handle elements hidden by overlays HOT 1
- How to use Cuprite with a remote browser (browserless/chrome) HOT 1
- BUG: select actions does not trigger "input" events (only "change" event) on select inputs/dropdowns
- Proxy does not get set
- How do I debug the behavior of this gem?
- Cuprite does not appear to support `evaluate_script` HOT 1
- Setting a color input doesn't fire the change or input events
- Process forking causing cuprite/ferrum to never exit HOT 1
- 500 error, possibly related to web sockets with Ferrum
- Race condition leading to `Argument should belong to the same JavaScript world as target object` HOT 2
- What the best way to play with multiple/new windows or tabs? HOT 1
- fill_in with empty string does not call addEventListener('input') HOT 1
- Visibility issue upon replacing hidden nodes (Race condition)
- keydown event sent without key property HOT 5
- Obsolete nodes are not refreshed when using Capybara's #within and/or #synchronize HOT 2
- Release that references ferrum 0.14.0
- Scraping Blocked on Indeed Site HOT 1
- Capybara::Cuprite::InvalidSelector
- Loading all JS files from asset pipeline and packs folder for testing with capybara/rspec
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cuprite.