Skip to content

Commit

Permalink
enable Puppeteer.connect(browser_url: http://localhost:9222)
Browse files Browse the repository at this point in the history
  • Loading branch information
YusukeIwaki committed Jun 23, 2020
1 parent a4510fc commit 5ff9adc
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/puppeteer/launcher/chrome.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def each(&block)
end
end

# @return [DefaultArgs]
def default_args(options = nil)
if options.nil?
@default_args ||= DefaultArgs.new(@chrome_arg_options)
Expand All @@ -147,8 +148,7 @@ def default_args(options = nil)
end
end

# @param {!(Launcher.BrowserOptions & {browserWSEndpoint?: string, browserURL?: string, transport?: !Puppeteer.ConnectionTransport})} options
# @return {!Promise<!Browser>}
# @return [Puppeteer::Browser]
def connect(options = {})
@browser_options = BrowserOptions.new(options)
browser_ws_endpoint = options[:browser_ws_endpoint]
Expand Down Expand Up @@ -187,11 +187,13 @@ def connect(options = {})

# @return [Puppeteer::Connection]
private def connect_with_browser_url(browser_url)
raise NotImplementedError.new('Puppeteer#connect with browserUrl is not implemented yet.')
# const connectionURL = await getWSEndpoint(browserURL);
# const connectionTransport = await WebSocketTransport.create(
# connectionURL
# );
require 'net/http'
uri = URI(browser_url)
uri.path = '/json/version'
response_body = Net::HTTP.get(uri)
json = JSON.parse(response_body)
connection_url = json['webSocketDebuggerUrl']
connect_with_browser_ws_endpoint(connection_url)
end

# @return [Puppeteer::Connection]
Expand Down

0 comments on commit 5ff9adc

Please sign in to comment.