Skip to content

Commit

Permalink
Allow execution of CDP commands when using Chrome
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Rodionov <p0deje@gmail.com>
  • Loading branch information
twalpole authored and p0deje committed Jan 12, 2019
1 parent 535eb7e commit 20e29a8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rb/lib/selenium/webdriver/chrome/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def quit
@service.stop if @service
end

def execute_cdp(cmd, **params)
@bridge.send_command(cmd: cmd, params: params)
end

private

def create_capabilities(opts)
Expand Down
14 changes: 14 additions & 0 deletions rb/spec/integration/selenium/webdriver/chrome/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ module Chrome
# there is no simple way to verify that it's now possible to download
# at least it doesn't crash
end

it 'can execute CDP commands' do
res = driver.execute_cdp('Page.addScriptToEvaluateOnNewDocument', source: 'window.was_here="TW";')
expect(res).to have_key('identifier')

begin
driver.navigate.to url_for('formPage.html')

tw = driver.execute_script('return window.was_here')
expect(tw).to eq('TW')
ensure
driver.execute_cdp('Page.removeScriptToEvaluateOnNewDocument', identifier: res['identifier'])
end
end
end
end # Chrome
end # WebDriver
Expand Down

0 comments on commit 20e29a8

Please sign in to comment.