Sha256: 0238af532199e69bbd6906224b38045af98520536cf3741ebcc90ca825ef9518

Contents?: true

Size: 1.5 KB

Versions: 16

Compression:

Stored size: 1.5 KB

Contents

class JavascriptPage
  include PageObject

  text_field(:expression, :id => 'calculator-expression')
  text_field(:results, :id => 'calculator-result')
  button(:compute, :value => 'Compute')

end

def build_url(page)
  target = ENV['BROWSER']
  return "http://localhost:4567/#{page}" if target.nil? or target.include? 'local'
  "http://ec2-107-22-131-88.compute-1.amazonaws.com:4567/#{page}"
end

Given /^I am on jQuery example page$/ do
  PageObject.javascript_framework = :jquery
  @page = JavascriptPage.new(@browser)
  @page.navigate_to build_url("jquery.html")
end

Given /^I am on the Prototype example page$/ do
  PageObject.javascript_framework = :prototype
  @page = JavascriptPage.new(@browser)
  @page.navigate_to build_url('prototype.html')
end

When /^I ask to compute "([^\"]*)"$/ do |expression|
  @page.expression = expression
  @page.compute
end

Then /^I should be able to wait for the answer "([^\"]*)"$/ do |answer|
  @page.wait_for_ajax
  @page.results.should == answer
end

Given /^I execute the javascript "([^\"]*)"$/ do |script|
  @answer = @page.execute_script script
end

Given /^I execute the javascript "([^\"]*)" with an argument of "([^\"]*)"$/ do |script, arg|
  @answer = @page.execute_script script, arg
end

Given /^I execute the javascript "([^\"]*)" with a text field argument$/ do |script|
  text_field = @page.text_field_element(:id => 'text_field_id')
  @page.execute_script(script, text_field)
end

Then /^I should get the answer "([^\"]*)"$/ do |answer|
  @answer.should == answer.to_i
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
page-object-1.2.0 features/step_definitions/javascript_steps.rb
page-object-1.1.1 features/step_definitions/javascript_steps.rb
page_object-1.1.3 features/step_definitions/javascript_steps.rb
page_object-1.1.2 features/step_definitions/javascript_steps.rb
page_object-1.1.1 features/step_definitions/javascript_steps.rb
page-object-1.1.0 features/step_definitions/javascript_steps.rb
page-object-1.0.3 features/step_definitions/javascript_steps.rb
meeane-page-object-0.1.11 features/step_definitions/javascript_steps.rb
page-object-1.0.2 features/step_definitions/javascript_steps.rb
page-object-1.0.1 features/step_definitions/javascript_steps.rb
page-object-1.0 features/step_definitions/javascript_steps.rb
page-object-0.9.8 features/step_definitions/javascript_steps.rb
page-object-0.9.7 features/step_definitions/javascript_steps.rb
page-object-0.9.6 features/step_definitions/javascript_steps.rb
page-object-0.9.5 features/step_definitions/javascript_steps.rb
page-object-0.9.4 features/step_definitions/javascript_steps.rb