Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add spec for Browser#execute_script running JS inside of an anonymous…

… function
  • Loading branch information...
commit c53a714dfebd7f100b27d4b593e2a90c991b3bd8 1 parent eef2f09
Jarmo Pertman jarmo authored

Showing 1 changed file with 6 additions and 0 deletions. Show diff stats Hide diff stats

  1. +6 0 browser_spec.rb
6 browser_spec.rb
@@ -175,6 +175,12 @@
175 175 browser.execute_script("document.getElementById('rspec').innerHTML = 'javascript text'")
176 176 browser.pre(:id, 'rspec').text.should == "javascript text"
177 177 end
  178 +
  179 + it "executes the given JavaScript in the context of an anonymous function" do
  180 + browser.goto(WatirSpec.url_for("non_control_elements.html"))
  181 + browser.execute_script("1 + 1").should == "undefined"
  182 + browser.execute_script("return 1 + 1").should == "2"
  183 + end
178 184 end
179 185
180 186 describe "#back and #forward" do

0 comments on commit c53a714

Jari Bakken

This should return nil, not "undefined". That's the equivalent value in Ruby.

Jarmo Pertman

I also thought about that, but was not sure since in JavaScript it will return undefined instead. So, what you're saying is that if the JS will return undefined in any way then it should be nil at ruby side?

E.g: execute_script("return") should return also nil?

Jari Bakken

Yes, exactly.

Please sign in to comment.
Something went wrong with that request. Please try again.