kendo-page-object-widgets 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kendo-page-object-widgets.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Kyle McKee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Kendo::Page::Object::Widgets
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/kendo/page/object/widgets`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'kendo-page-object-widgets'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install kendo-page-object-widgets
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/[my-github-username]/kendo-page-object-widgets/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kendo-page-object-widgets"
8
+ spec.version = KendoPageObjectWidgets::VERSION
9
+ spec.authors = ["Kyle McKee"]
10
+ spec.email = ["mckee.kyle@gmail.com"]
11
+
12
+ if spec.respond_to?(:metadata)
13
+ spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
14
+ end
15
+
16
+ spec.summary = %q{Kendo Widgets}
17
+ spec.description = %q{This gem adds kendo widgets to your page-objects}
18
+ spec.homepage = "http://github.sherwin.com/kxm827/kendo-page-object-widgets"
19
+ spec.license = "MIT"
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ spec.bindir = "exe"
23
+ #spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.8"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_dependency "page-object"
29
+ end
@@ -0,0 +1,14 @@
1
+ require 'version'
2
+ require 'page-object'
3
+ require_relative 'widgets/kendo_auto_complete_input'
4
+ require_relative 'widgets/kendo_auto_complete_select_list'
5
+ require_relative 'widgets/kendo_cascading_select_list'
6
+ require_relative 'widgets/kendo_select_list'
7
+
8
+ module KendoPageObjectWidgets
9
+ PageObject.register_widget(:auto_complete_input, Widgets::KendoAutoCompleteInput, 'text_field')
10
+ PageObject.register_widget(:auto_complete_select_list, Widgets::KendoAutoCompleteSelectList, 'text_field')
11
+ PageObject.register_widget(:cascading_drop_down, Widgets::KendoCascadingSelectList, 'text_field')
12
+ PageObject.register_widget(:kendo_select_list, Widgets::KendoSelectList, 'text_field')
13
+ end
14
+
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module KendoPageObjectWidgets
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,37 @@
1
+ module KendoPageObjectWidgets
2
+ module Widgets
3
+ class KendoAutoCompleteInput < PageObject::Elements::TextField
4
+
5
+ def self.accessor_methods(accessor, name)
6
+
7
+ accessor.send :define_method, "#{name}=" do |value|
8
+ self.send("#{name}_element").value= value
9
+ self.send("#{name}_options_container").when_visible
10
+ self.send("#{name}_element").send_keys :tab
11
+ end
12
+
13
+ accessor.send :define_method, "#{name}_text=" do |value|
14
+ self.send("#{name}_element").append(value)
15
+ end
16
+
17
+ accessor.send :define_method, "#{name}_valid?" do
18
+ !self.send("#{name}_element").attribute('class').include? 'input-validation-error'
19
+ end
20
+
21
+ #private
22
+
23
+ accessor.send :define_method, "#{name}_options_container" do
24
+ self.platform.div_for(:id => "#{self.send("#{name}_id")}-list")
25
+ end
26
+
27
+ accessor.send :define_method, "#{name}_id" do
28
+ self.send("#{name}_element").attribute('id')
29
+ end
30
+
31
+ accessor.send :private, "#{name}_options_container", "#{name}_id"
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+
@@ -0,0 +1,78 @@
1
+ module KendoPageObjectWidgets
2
+ module Widgets
3
+ class KendoAutoCompleteSelectList < PageObject::Elements::TextField
4
+
5
+ def self.accessor_methods(accessor, name)
6
+
7
+ accessor.send :define_method, "#{name}_filter=" do |value|
8
+ self.send("#{name}_text_field").value = value
9
+ self.send("#{name}_options_container").when_visible
10
+ end
11
+
12
+ accessor.send :define_method, "#{name}_text=" do |text|
13
+ text_field = self.send("#{name}_text_field")
14
+ text_field.value = text
15
+ sleep 0.5
16
+ text_field.send_keys :tab
17
+ end
18
+
19
+ accessor.send :define_method, "#{name}=" do |value|
20
+ self.send("#{name}_filter=", value)
21
+ self.send("#{name}_text_field").send_keys :tab
22
+ end
23
+
24
+ accessor.send :define_method, "#{name}_valid?" do
25
+ !self.send("#{name}_text_field").attribute('class').include? 'input-validation-error'
26
+ end
27
+
28
+ accessor.send :define_method, "#{name}_options" do
29
+ self.send("#{name}_opener")
30
+ options = self.send("#{name}_options_list")
31
+ options.map { |li| li.text }
32
+ end
33
+
34
+ accessor.send :define_method, "#{name}_suggestions" do
35
+ options = self.send("#{name}_options_list")
36
+ options.map { |li| li.text }
37
+ end
38
+
39
+ accessor.send :define_method, "#{name}_text" do
40
+ self.send("#{name}_text_field").text
41
+ end
42
+
43
+ #private
44
+
45
+ accessor.send :define_method, "#{name}_opener" do
46
+ container = self.send("#{name}_options_container")
47
+ self.send("#{name}_select_list_opener").click unless container.visible?
48
+ container.when_visible
49
+ end
50
+
51
+ accessor.send :define_method, "#{name}_options_container" do
52
+ self.platform.div_for(:id => "#{self.send("#{name}_id")}-list")
53
+ end
54
+
55
+ accessor.send :define_method, "#{name}_options_list" do
56
+ self.platform.unordered_list_for(:id => "#{self.send("#{name}_id")}_listbox")
57
+ end
58
+
59
+ accessor.send :define_method, "#{name}_text_field" do
60
+ self.platform.text_field_for(:name => "#{self.send("#{name}_id")}_input")
61
+ end
62
+
63
+ accessor.send :define_method, "#{name}_select_list_opener" do
64
+ self.send("#{name}_element").parent.span_element.span_element
65
+ end
66
+
67
+ accessor.send :define_method, "#{name}_id" do
68
+ self.send("#{name}_element").attribute('id')
69
+ end
70
+
71
+ accessor.send :private, "#{name}_text_field", "#{name}_id", "#{name}_select_list_opener", "#{name}_options_list", "#{name}_options_container", "#{name}_opener"
72
+
73
+ end
74
+
75
+ end
76
+ end
77
+ end
78
+
@@ -0,0 +1,60 @@
1
+ module KendoPageObjectWidgets
2
+ module Widgets
3
+ class KendoCascadingSelectList < PageObject::Elements::TextField
4
+
5
+ def visible?
6
+ self.parent.visible?
7
+ end
8
+
9
+ def self.accessor_methods(accessor, name)
10
+
11
+ accessor.send :define_method, "#{name}=" do |value|
12
+ wait_until { self.send("is_#{name}_enabled?") }
13
+ self.send("click_opener_for_#{name}")
14
+ unless value.empty?
15
+ options = self.send("get_#{name}_options")
16
+ list_item = options.list_item_element(:text => value.strip)
17
+ list_item.click
18
+ end
19
+ end
20
+
21
+ accessor.send :define_method, "#{name}_options" do
22
+ options = self.send("get_#{name}_options")
23
+ options.map { |li| li.text }
24
+ end
25
+
26
+ #private
27
+ accessor.send :define_method, "get_#{name}_options" do
28
+ container = self.send("#{name}_options_container")
29
+ unless container.visible?
30
+ self.send("click_opener_for_#{name}")
31
+ container.when_visible
32
+ end
33
+ self.send("#{name}_options_list")
34
+ end
35
+
36
+ accessor.send :define_method, "#{name}_options_container" do
37
+ self.element('div', :id => "#{self.send("#{name}_id")}-list")
38
+ end
39
+
40
+ accessor.send :define_method, "click_opener_for_#{name}" do
41
+ self.send("#{name}_element").parent.span_element.span_element.click
42
+ end
43
+
44
+ accessor.send :define_method, "#{name}_options_list" do
45
+ self.platform.unordered_list_for(:id => "#{self.send("#{name}_id")}_listbox")
46
+ end
47
+
48
+ accessor.send :define_method, "#{name}_id" do
49
+ self.send("#{name}_element").attribute('id')
50
+ end
51
+
52
+ accessor.send :define_method, "is_#{name}_enabled?" do
53
+ self.send("#{name}_element").parent.attribute('aria-disabled') == "false"
54
+ end
55
+
56
+ accessor.send :private, "get_#{name}_options", "#{name}_options_list", "#{name}_options_container", "click_opener_for_#{name}", "#{name}_id", "is_#{name}_enabled?"
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,73 @@
1
+ module KendoPageObjectWidgets
2
+ module Widgets
3
+ class KendoSelectList < PageObject::Elements::TextField
4
+
5
+ def visible?
6
+ self.parent.visible?
7
+ end
8
+
9
+ def self.accessor_methods(accessor, name)
10
+
11
+ accessor.send :define_method, "#{name}_options" do
12
+ options = self.send("get_#{name}_options")
13
+ options.map { |li| li.text }
14
+ end
15
+
16
+ accessor.send :define_method, "#{name}=" do |value|
17
+ unless value.empty?
18
+ self.send("click_opener_for_#{name}")
19
+ options = self.send("get_#{name}_options")
20
+ list_item = options.list_item_element(:text => value.strip)
21
+ list_item.click
22
+ end
23
+ end
24
+
25
+ accessor.send :define_method, "#{name}" do
26
+ selected_option = self.send("#{name}_selected")
27
+ puts selected_option.text
28
+ selected_option.text
29
+ end
30
+
31
+ accessor.send :define_method, "#{name}_valid?" do
32
+ !self.send("#{name}_text_field").attribute('class').include? 'input-validation-error'
33
+ end
34
+
35
+ #private
36
+ accessor.send :define_method, "get_#{name}_options" do
37
+ container = self.send("#{name}_options_container")
38
+ unless container.visible?
39
+ self.send("click_opener_for_#{name}")
40
+ container.when_visible
41
+ end
42
+ self.send("#{name}_options_list")
43
+ end
44
+
45
+ accessor.send :define_method, "#{name}_options_container" do
46
+ self.element('div', :id => "#{self.send("#{name}_id")}-list")
47
+ end
48
+
49
+ accessor.send :define_method, "#{name}_options_list" do
50
+ self.platform.unordered_list_for(:id => "#{self.send("#{name}_id")}_listbox")
51
+ end
52
+
53
+ accessor.send :define_method, "click_opener_for_#{name}" do
54
+ self.send("#{name}_element").parent.span_element.span_element.click
55
+ end
56
+
57
+ accessor.send :define_method, "#{name}_id" do
58
+ self.send("#{name}_element").attribute('id')
59
+ end
60
+
61
+ accessor.send :define_method, "#{name}_text_field" do
62
+ self.send("#{name}_element").parent.text_field_element
63
+ end
64
+
65
+ accessor.send :define_method, "#{name}_selected" do
66
+ self.send("#{name}_element").parent.span_element(:class => 'k-input')
67
+ end
68
+
69
+ accessor.send :private, "#{name}_selected", "#{name}_text_field", "#{name}_id", "click_opener_for_#{name}", "#{name}_options_list", "#{name}_options_container", "get_#{name}_options"
70
+ end
71
+ end
72
+ end
73
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kendo-page-object-widgets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kyle McKee
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2015-03-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.8'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.8'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '10.0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '10.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: page-object
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: This gem adds kendo widgets to your page-objects
63
+ email:
64
+ - mckee.kyle@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - .rspec
71
+ - .travis.yml
72
+ - Gemfile
73
+ - LICENSE.txt
74
+ - README.md
75
+ - Rakefile
76
+ - kendo-page-object-widgets-0.1.0.gem
77
+ - kendo-page-object-widgets.gemspec
78
+ - lib/kendo-page-object-widgets.rb
79
+ - lib/version.rb
80
+ - lib/widgets/kendo_auto_complete_input.rb
81
+ - lib/widgets/kendo_auto_complete_select_list.rb
82
+ - lib/widgets/kendo_cascading_select_list.rb
83
+ - lib/widgets/kendo_select_list.rb
84
+ homepage: http://github.sherwin.com/kxm827/kendo-page-object-widgets
85
+ licenses:
86
+ - MIT
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 1.8.29
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: Kendo Widgets
109
+ test_files: []