Skip to content

Commit

Permalink
Test define_page_methods and require_all_pages
Browse files Browse the repository at this point in the history
  • Loading branch information
bootstraponline committed Jun 22, 2015
1 parent 83a4d30 commit 1e190f2
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions angular_webdriver.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'appium_thor', '>= 1.0.1'
s.add_development_dependency 'pry', '>= 0.10.1'
s.add_development_dependency 'trace_files', '>= 1.0.0'
s.add_development_dependency 'page_object', '>= 1.1.3' # for page_object_spec

s.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(gen|test|spec|features|protractor)/})
Expand Down
12 changes: 12 additions & 0 deletions page/local_page.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# http://localhost:8081/#/form
module Page
class LocalPage
include PageObject

page_url 'http://localhost:8081/#/form'
element(:greet_button) { element(by.binding('greet')) }

# alternatively just use the symbol name
element(:greet_button2, binding: 'greet')
end
end
6 changes: 4 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# angular_webdriver

[![Gem Version](https://badge.fury.io/rb/angular_webdriver.svg)](https://rubygems.org/gems/angular_webdriver) [![Build Status](https://travis-ci.org/bootstraponline/angular_webdriver.svg?branch=master)](https://travis-ci.org/bootstraponline/angular_webdriver/builds) [![Coverage Status](https://coveralls.io/repos/bootstraponline/angular_webdriver/badge.svg?nocache)](https://coveralls.io/r/bootstraponline/angular_webdriver) [![Dependency Status](https://gemnasium.com/bootstraponline/angular_webdriver.svg?nocache)](https://gemnasium.com/bootstraponline/angular_webdriver)

[![Gem Version](https://badge.fury.io/rb/angular_webdriver.svg)](https://rubygems.org/gems/angular_webdriver)
[![Build Status](https://travis-ci.org/bootstraponline/angular_webdriver.svg?branch=master)](https://travis-ci.org/bootstraponline/angular_webdriver/builds)
[![Coverage Status](https://coveralls.io/repos/bootstraponline/angular_webdriver/badge.svg?nocach)](https://coveralls.io/r/bootstraponline/angular_webdriver)
[![Dependency Status](https://gemnasium.com/bootstraponline/angular_webdriver.svg?nocache)](https://gemnasium.com/bootstraponline/angular_webdriver)

Angular enhancements to the Ruby webdriver bindings based on [protractor](https://github.com/angular/protractor).

Expand Down
6 changes: 6 additions & 0 deletions spec/helpers/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ def initialize
end
end

# override stub methods
AngularWebdriver.define_page_methods page_module: ::Page,
target_class: context,
method: :define_method,
watir: browser

# set script timeout for protractor client side javascript
# https://github.com/angular/protractor/issues/117
_60_seconds = 60
Expand Down
10 changes: 10 additions & 0 deletions spec/page_object_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require_relative 'spec_helper'

describe 'page object' do
it 'finds by custom protractor locator' do
local_page.goto
element(by.binding('greet')).present? # protractor locator can be used directly
local_page.greet_button? # or inside a page object via block
local_page.greet_button2? # or inside a page object via symbol
end
end
3 changes: 3 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
add_filter '/spec'
end

require 'page_object'
require 'watir-webdriver'
require 'pry'
require 'webdriver_utils'
Expand All @@ -25,6 +26,8 @@

Pry.pager = nil if defined?(Pry) # disable pry paging

AngularWebdriver.require_all_pages

# Define browser name at top level to selectively exclude browser specific
# tests within the spec files
def browser_name
Expand Down

0 comments on commit 1e190f2

Please sign in to comment.