Skip to content

Commit

Permalink
Test debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
bootstraponline committed May 21, 2015
1 parent 1342439 commit f2945ca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/angular_webdriver/protractor/protractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,19 @@ def executeScript_ script, description, *args
driver.execute_script script, *args
end

# Adds a task to the control flow to pause the test and inject helper functions
# into the browser, so that debugging may be done in the browser console.
# Injects window.clientSideScripts object with all the Protractor client
# side scripts. Example:
#
# This should be used under Pry
# ```ruby
# # inject the scripts
# protractor.debugger
#
# # now that the scripts are injected, they can be used via execute_script
# driver.execute_script "window.clientSideScripts.getLocationAbsUrl('body')"
# ```
#
# This should be used under Pry. The window client side scripts can be
# invoked using chrome dev tools after calling debugger.
def debugger
executeScript_ client_side_scripts.install_in_browser, 'Protractor.debugger()'
end
Expand Down
7 changes: 7 additions & 0 deletions spec/protractor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ def async_two_arg
expected = 3
expect_equal actual, expected
end

it 'debugger' do
protractor.debugger
actual = driver.execute_script "return typeof window.clientSideScripts === 'object'"
expected = true
expect_equal actual, expected
end
end


Expand Down

0 comments on commit f2945ca

Please sign in to comment.