selenium_dsl 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/.idea/.name ADDED
@@ -0,0 +1 @@
1
+ selenium_dsl
data/.idea/.rakeTasks ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
4
+ </project>
5
+
data/.idea/misc.xml ADDED
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-1.9.3-p385 [selenium_dsl]" project-jdk-type="RUBY_SDK" />
4
+ </project>
5
+
data/.idea/modules.xml ADDED
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/selenium_dsl.iml" filepath="$PROJECT_DIR$/.idea/selenium_dsl.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
9
+
@@ -0,0 +1,5 @@
1
+ <component name="DependencyValidationManager">
2
+ <state>
3
+ <option name="SKIP_IMPORT_STATEMENTS" value="false" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,37 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="FacetManager">
4
+ <facet type="gem" name="Gem">
5
+ <configuration>
6
+ <option name="GEM_APP_ROOT_PATH" value="" />
7
+ <option name="GEM_APP_TEST_PATH" value="" />
8
+ <option name="GEM_APP_LIB_PATH" value="" />
9
+ </configuration>
10
+ </facet>
11
+ </component>
12
+ <component name="NewModuleRootManager">
13
+ <content url="file://$MODULE_DIR$" />
14
+ <orderEntry type="inheritedJdk" />
15
+ <orderEntry type="sourceFolder" forTests="false" />
16
+ <orderEntry type="library" scope="PROVIDED" name="archive-tar-minitar (v0.5.2, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.2.3, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="columnize (v0.3.6, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.1.3, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="file_utils (v1.0.6, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="gemcutter (v0.7.1, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="gemspec_deps_gen (v1.0.5, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="linecache19 (v0.5.13, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="metaclass (v0.0.1, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="mocha (v0.13.2, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="rake (v10.0.3, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v2.12.0, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v2.12.2, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v2.12.1, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v2.12.2, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="ruby-debug-base19x (v0.11.30.pre10, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="ruby-debug-ide (v0.4.17.beta14, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="ruby_core_source (v0.1.5, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="selenium-client (v1.2.18, RVM: ruby-1.9.3-p385 [selenium_dsl]) [gem]" level="application" />
35
+ </component>
36
+ </module>
37
+
data/.idea/vcs.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
7
+
data/.rvmrc ADDED
@@ -0,0 +1,4 @@
1
+ rvm_gemset_create_on_use_flag=1
2
+ rvm_pretty_print_flag=1
3
+
4
+ rvm use 1.9.3@selenium_dsl
data/CHANGES ADDED
@@ -0,0 +1,5 @@
1
+ = Selenium DSL Changelog
2
+
3
+ == Version 1.0.0
4
+
5
+ * Initial release.
data/Gemfile ADDED
@@ -0,0 +1,28 @@
1
+ source :rubygems
2
+
3
+ gem "selenium-client"
4
+
5
+ group :development do
6
+ gem "gemspec_deps_gen"
7
+ gem "gemcutter"
8
+ end
9
+
10
+ group :test do
11
+ gem "rspec"
12
+ gem "rspec-core"
13
+ gem "rspec-expectations"
14
+ gem "mocha"
15
+ end
16
+
17
+ group :debug do
18
+ if RUBY_VERSION.include? "1.9"
19
+ unless File.exist? "#{ENV['GEM_HOME']}/gems/linecache19-0.5.13/lib/linecache19.rb"
20
+ `curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem`
21
+ `gem i linecache19-0.5.13.gem`
22
+ end
23
+
24
+ gem "linecache19", "0.5.13"
25
+ gem "ruby-debug-base19x", "0.11.30.pre10"
26
+ gem "ruby-debug-ide", "0.4.17.beta14"
27
+ end
28
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,49 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ archive-tar-minitar (0.5.2)
5
+ columnize (0.3.6)
6
+ diff-lcs (1.1.3)
7
+ file_utils (1.0.6)
8
+ gemcutter (0.7.1)
9
+ gemspec_deps_gen (1.0.5)
10
+ file_utils
11
+ linecache19 (0.5.13)
12
+ ruby_core_source (>= 0.1.4)
13
+ metaclass (0.0.1)
14
+ mocha (0.13.2)
15
+ metaclass (~> 0.0.1)
16
+ rake (10.0.3)
17
+ rspec (2.12.0)
18
+ rspec-core (~> 2.12.0)
19
+ rspec-expectations (~> 2.12.0)
20
+ rspec-mocks (~> 2.12.0)
21
+ rspec-core (2.12.2)
22
+ rspec-expectations (2.12.1)
23
+ diff-lcs (~> 1.1.3)
24
+ rspec-mocks (2.12.2)
25
+ ruby-debug-base19x (0.11.30.pre10)
26
+ columnize (>= 0.3.1)
27
+ linecache19 (>= 0.5.11)
28
+ rake (>= 0.8.1)
29
+ ruby_core_source (>= 0.1.4)
30
+ ruby-debug-ide (0.4.17.beta14)
31
+ rake (>= 0.8.1)
32
+ ruby_core_source (0.1.5)
33
+ archive-tar-minitar (>= 0.5.2)
34
+ selenium-client (1.2.18)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ gemcutter
41
+ gemspec_deps_gen
42
+ linecache19 (= 0.5.13)
43
+ mocha
44
+ rspec
45
+ rspec-core
46
+ rspec-expectations
47
+ ruby-debug-base19x (= 0.11.30.pre10)
48
+ ruby-debug-ide (= 0.4.17.beta14)
49
+ selenium-client
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Alexander Shvets
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # SeleniumDSL - Simple way to build Selenium code as DSL
2
+
3
+ ## Installation
4
+
5
+ Add this line to to your Gemfile:
6
+
7
+ gem "selenium_dsl"
8
+
9
+ And then execute:
10
+
11
+ $ bundle
12
+
13
+ ## Usage
14
+
15
+ ```ruby
16
+ require 'selenium_dsl'
17
+
18
+ include SeleniumDSL::DSL
19
+
20
+ selenium_server_address = 'localhost'
21
+ selenium_server_port = 4444
22
+ selenium_browser_key = '*firefox'
23
+ timeout_in_seconds = 40
24
+
25
+ webapp_url = "http://localhost:3000/web_app_name"
26
+
27
+ init_selenium(selenium_server_address, selenium_server_port, selenium_browser_key, webapp_url, timeout_in_seconds)
28
+
29
+ start_new_session
30
+
31
+ selenium do
32
+ open "/#{application_name}"
33
+
34
+ click "some_link"
35
+
36
+ fill_in("some_field", :with => "some_value")
37
+ end
38
+
39
+ close_session
40
+
41
+ ```
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env rake
2
+
3
+ $LOAD_PATH.unshift File.expand_path("lib", File.dirname(__FILE__))
4
+
5
+ require "rspec/core/rake_task"
6
+ require "selenium_dsl/version"
7
+ require "gemspec_deps_gen/gemspec_deps_gen"
8
+
9
+ def version
10
+ SeleniumDSL::VERSION
11
+ end
12
+
13
+ def project_name
14
+ File.basename(Dir.pwd)
15
+ end
16
+
17
+ task :build do
18
+ system "rm #{project_name}.gemspec"
19
+ generator = GemspecDepsGen.new
20
+
21
+ generator.generate_dependencies "#{project_name}.gemspec.erb", "#{project_name}.gemspec"
22
+
23
+ system "gem build #{project_name}.gemspec"
24
+ end
25
+
26
+ task :install do
27
+ system "gem install #{project_name}-#{version}.gem"
28
+ end
29
+
30
+ task :release => :build do
31
+ system "gem push #{project_name}-#{version}.gem"
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new do |task|
35
+ task.pattern = 'spec/**/*_spec.rb'
36
+ task.verbose = false
37
+ end
@@ -0,0 +1,6 @@
1
+ require 'rubygems' unless Object.const_defined?(:Gem)
2
+
3
+ require 'selenium_dsl/proxy'
4
+ require 'selenium_dsl/script'
5
+ require 'selenium_dsl/dsl'
6
+ require 'selenium_dsl/version'
@@ -0,0 +1,31 @@
1
+ require "selenium/client"
2
+ require 'selenium_dsl/proxy'
3
+
4
+ module SeleniumDSL
5
+ module DSL
6
+ def init_selenium(host, port, browser, url, timeout_in_seconds)
7
+ @selenium_driver = Selenium::Client::Driver.new \
8
+ :host => host,
9
+ :port => port,
10
+ :browser => browser,
11
+ :url => url,
12
+ :timeout_in_seconds => timeout_in_seconds
13
+
14
+ @script = Script.new @selenium_driver, timeout_in_seconds
15
+ end
16
+
17
+ def start_new_session
18
+ @selenium_driver.start_new_browser_session
19
+ end
20
+
21
+ def close_session
22
+ @selenium_driver.close_current_browser_session
23
+ end
24
+
25
+ def selenium(&block)
26
+ @script.instance_eval(&block)
27
+
28
+ @script
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,37 @@
1
+ module SeleniumDSL
2
+ if RUBY_VERSION.to_f < 1.9
3
+ class BlankSlate
4
+ instance_methods.each { |m| undef_method m unless m =~ /^__|instance_eval|object_id/ }
5
+ end
6
+
7
+ PROXY_CLASS = BlankSlate
8
+ else
9
+ PROXY_CLASS = BasicObject
10
+ end
11
+
12
+ class Proxy < PROXY_CLASS
13
+ def initialize subject, methods_to_override=[]
14
+ @subject = subject
15
+
16
+ singleton_class = (class << self; self; end)
17
+
18
+ # these methods are already defined in core classes: we need to override them
19
+ methods_to_override.each do |method|
20
+ singleton_class.send :define_method, method do |*args|
21
+ @subject.send method, *args
22
+ end
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def method_missing(name, *args, &block)
29
+ @subject.send(name, *args, &block)
30
+ end
31
+
32
+ def respond_to?(method)
33
+ @subject.respond_to?(method)
34
+ super
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,198 @@
1
+ require 'selenium_dsl/proxy'
2
+
3
+ module SeleniumDSL
4
+ class Script < Proxy
5
+
6
+ def initialize selenium_driver, timeout_in_seconds
7
+ super selenium_driver, [:open, :select, :type]
8
+
9
+ @page = selenium_driver
10
+ @timeout_in_seconds = timeout_in_seconds
11
+ end
12
+
13
+ def timeout_in_seconds
14
+ @timeout_in_seconds
15
+ end
16
+
17
+ def click locator, *params
18
+ @page.click locator, *params
19
+
20
+ if params.size > 0
21
+ @page.wait_for_condition "selenium.browserbot.getCurrentWindow().jQuery.active == 0" if params[0][:ajax] == true
22
+
23
+ @page.wait_for_page_to_load @timeout_in_seconds if params[0][:wait] == true
24
+ end
25
+ end
26
+
27
+ # def select_value value, element, prefix
28
+ # @page.select "#{prefix}_#{element}", "value=#{value}"
29
+ # end
30
+
31
+ def check_select value, element, prefix
32
+ @page.click full_input_name(prefix, element)
33
+ end
34
+
35
+ def full_input_name(prefix, input_name)
36
+ prefix ? "#{prefix}_#{input_name}" : input_name
37
+ end
38
+
39
+ def session_id
40
+ /session_id=(\w+)/.match(@page.get_cookie)[1]
41
+ end
42
+
43
+ # def enter value, element, prefix
44
+ # @page.type "#{prefix}_#{element}", value
45
+ # end
46
+
47
+ def radio_select value, element, prefix
48
+ if prefix.nil?
49
+ @page.click "id=#{value}"
50
+ else
51
+ @page.click "#{prefix}_#{element}_#{value}"
52
+ end
53
+ end
54
+
55
+ def go_back
56
+ @page.go_back
57
+ end
58
+
59
+ # def new_session(path)
60
+ # open(path)
61
+ # end
62
+
63
+ # def goto path
64
+ # @page.open path
65
+ # end
66
+
67
+ # def reset_session
68
+ # @page.delete_cookie('_proteus_session', '/')
69
+ # @page.delete_cookie('login', '/')
70
+ # end
71
+
72
+ # def select_value value, element, prefix
73
+ # @page.select "#{prefix}_#{element}", "value=#{value}"
74
+ # end
75
+
76
+ def wait_for_text value, element_id, timeout=10000
77
+ script = <<-EOF
78
+ var element = #{selenium_get_element_by_id(element_id)};
79
+ var included = false;
80
+ if (element.value == '#{value}') included = true;
81
+ included;
82
+ EOF
83
+ @page.wait_for_condition(script, timeout)
84
+ end
85
+
86
+ def wait_for_option(value, element, prefix, timeout=30000)
87
+ option_list = "#{prefix}_#{element}"
88
+ script = <<-EOF
89
+ var option_list = #{selenium_get_element_by_id(option_list)};
90
+ var included = false;
91
+
92
+ if( option_list != null && option_list.length > 0 ) {
93
+ for( x=0; x < option_list.length; x++ ) {
94
+ if( option_list[x] != null ) {
95
+ if( option_list[x].value == '#{value}' ) included = true;
96
+ }
97
+ }
98
+ }
99
+
100
+ included;
101
+ EOF
102
+
103
+ @page.wait_for_condition(script, timeout)
104
+ end
105
+
106
+ def wait_until_enabled( element_id, timeout=10000)
107
+ @page.wait_for_condition(
108
+ "selenium.browserbot.getCurrentWindow()." +
109
+ "document.getElementById('#{element_id}').disabled == false;",
110
+ timeout
111
+ )
112
+ end
113
+
114
+ # def assert_title(expected_value)
115
+ # assert_equal expected_value, @page.get_title, "Expected title to be: '#{expected_value}' but was '#{@page.get_title}'"
116
+ # end
117
+ #
118
+ # def assert_contains text, message=nil
119
+ # assert(contains?(text), message.nil? ? "Expected to find text '#{text}'" : message)
120
+ # end
121
+ #
122
+ # def assert_not_contains text
123
+ # assert !contains?(text), "Expected not to find text '#{text}'"
124
+ # end
125
+ #
126
+ # def assert_value(expected_value, element)
127
+ # assert_equal expected_value, @page.get_value(element)
128
+ # end
129
+
130
+ def contains? text
131
+ /#{text}/ =~ @page.get_html_source
132
+ end
133
+
134
+ # def assert_selected value, element, prefix
135
+ # id = prefix.blank? ? "#{element}" : "#{prefix}[#{element}]"
136
+ # assert_equal value, @page.get_selected_value("#{id}")
137
+ # end
138
+
139
+ def match_element id
140
+ Regexp.new("<([^>]*)(id *= *['\"]?#{id}['\"]?)([^>]*)>", Regexp::IGNORECASE).match(@page.get_html_source)
141
+ end
142
+
143
+ def visible? element
144
+ element_tag = element.to_a[0]
145
+
146
+ return false if element_tag.nil?
147
+
148
+ Regexp.new(".*display:none.*").match(element_tag.gsub(' ', '').downcase).nil?
149
+ end
150
+
151
+ # def assert_shown id
152
+ # element = match_element(id)
153
+ #
154
+ # assert(!element.nil? && visible?(element))
155
+ # end
156
+ #
157
+ # def assert_hidden id
158
+ # element = match_element(id)
159
+ #
160
+ # assert(!element.nil? && !visible?(element))
161
+ # end
162
+ #
163
+ # def assert_exists id
164
+ # assert_not_nil(match_element(id))
165
+ # end
166
+ #
167
+ # def assert_does_not_exist id
168
+ # assert_nil(match_element(id))
169
+ # end
170
+
171
+ protected
172
+
173
+ def selenium_get_element_by_id(id)
174
+ "#{selenium_window}.document.getElementById('#{id}')"
175
+ end
176
+
177
+ def selenium_window
178
+ "selenium.browserbot.getCurrentWindow()"
179
+ end
180
+
181
+ def remove_element(id)
182
+ wait_for_condition "#{selenium_get_element_by_id(id)}.remove()", 10000
183
+ end
184
+
185
+ def wait_for_element(id)
186
+ wait_for_condition "#{selenium_get_element_by_id(id)} != null", 10000
187
+ end
188
+
189
+ def response_body
190
+ @page.get_html_source
191
+ end
192
+
193
+ def text_for id
194
+ @page.get_text(id)
195
+ end
196
+
197
+ end
198
+ end
@@ -0,0 +1,3 @@
1
+ module SeleniumDSL
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/lib/selenium_dsl/version')
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "selenium_dsl"
7
+ spec.summary = %q{Simple way to build Selenium code as DSL.}
8
+ spec.description = %q{Simple way to build Selenium code as DSL}
9
+ spec.email = "alexander.shvets@gmail.com"
10
+ spec.authors = ["Alexander Shvets"]
11
+ spec.homepage = "http://github.com/shvets/selenium_dsl"
12
+
13
+ spec.files = `git ls-files`.split($\)
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+ spec.version = SeleniumDSL::VERSION
17
+
18
+ spec.add_runtime_dependency "selenium-client", [">= 0"]
19
+ spec.add_development_dependency "gemspec_deps_gen", [">= 0"]
20
+ spec.add_development_dependency "gemcutter", [">= 0"]
21
+
22
+ end
23
+
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/lib/selenium_dsl/version')
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "selenium_dsl"
7
+ spec.summary = %q{Simple way to build Selenium code as DSL.}
8
+ spec.description = %q{Simple way to build Selenium code as DSL}
9
+ spec.email = "alexander.shvets@gmail.com"
10
+ spec.authors = ["Alexander Shvets"]
11
+ spec.homepage = "http://github.com/shvets/selenium_dsl"
12
+
13
+ spec.files = `git ls-files`.split($\)
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+ spec.version = SeleniumDSL::VERSION
17
+
18
+ <%= include_dependencies %>
19
+ end
20
+
@@ -0,0 +1,54 @@
1
+ # access_webapp_spec.rb
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
+
5
+ describe "access wikipedia" do
6
+
7
+ it_should_behave_like :SeleniumTest do
8
+ before :all do
9
+ config = load_configuration
10
+
11
+ puts "Application: #{config['webapp_url']}"
12
+ puts "Selenium: #{config['selenium_server_address']}:#{config['selenium_server_port']}"
13
+
14
+ init_selenium(config['selenium_server_address'], config['selenium_server_port'].to_i,
15
+ config['selenium_browser_key'], config['webapp_url'], config['timeout_in_seconds'])
16
+ end
17
+
18
+ it "should submit the request" do
19
+ selenium do
20
+ open "/"
21
+
22
+ is_text_present("The Free Encyclopedia").should be_true
23
+
24
+ type "searchInput", "iphone"
25
+
26
+ click "go", :wait => true
27
+
28
+ is_text_present("iPhone").should be_true
29
+ end
30
+
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def load_configuration
37
+ config = {
38
+ 'application_address' => 'www.wikipedia.org',
39
+ 'application_port' => '80',
40
+ 'application_name' => '',
41
+ 'selenium_server_address' => 'localhost',
42
+ 'selenium_server_port' => '4444',
43
+ 'selenium_browser_key' => '*firefox',
44
+ 'timeout_in_seconds' => 40
45
+ }
46
+
47
+ webapp_url = "http://#{config['application_address']}:#{config['application_port']}/#{config['application_name']}"
48
+
49
+ config['webapp_url'] = webapp_url
50
+
51
+ config
52
+ end
53
+
54
+ end
@@ -0,0 +1,30 @@
1
+ require 'rubygems' unless Object.const_defined?(:Gem)
2
+
3
+ # add lib directory
4
+ $:.unshift File.dirname(__FILE__) + '/../lib'
5
+
6
+ require "selenium_dsl"
7
+
8
+ SeleniumDSL::Script.send :include, RSpec::Matchers
9
+
10
+ RSpec.configuration.include(SeleniumDSL::DSL)
11
+
12
+ module Selenium::Client::Base
13
+ alias originalInitialize initialize
14
+
15
+ def initialize(*args)
16
+ originalInitialize *args
17
+
18
+ @highlight_located_element_by_default = true
19
+ end
20
+ end
21
+
22
+ share_examples_for :SeleniumTest do
23
+ before :each do
24
+ start_new_session
25
+ end
26
+
27
+ after :each do
28
+ close_session
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: selenium_dsl
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alexander Shvets
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: selenium-client
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: gemspec_deps_gen
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '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: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: gemcutter
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
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: Simple way to build Selenium code as DSL
63
+ email: alexander.shvets@gmail.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - .gitignore
69
+ - .idea/.name
70
+ - .idea/.rakeTasks
71
+ - .idea/encodings.xml
72
+ - .idea/misc.xml
73
+ - .idea/modules.xml
74
+ - .idea/scopes/scope_settings.xml
75
+ - .idea/selenium_dsl.iml
76
+ - .idea/vcs.xml
77
+ - .rvmrc
78
+ - CHANGES
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE
82
+ - README.md
83
+ - Rakefile
84
+ - lib/selenium_dsl.rb
85
+ - lib/selenium_dsl/dsl.rb
86
+ - lib/selenium_dsl/proxy.rb
87
+ - lib/selenium_dsl/script.rb
88
+ - lib/selenium_dsl/version.rb
89
+ - selenium_dsl.gemspec
90
+ - selenium_dsl.gemspec.erb
91
+ - spec/access_wikipedia_spec.rb
92
+ - spec/spec_helper.rb
93
+ homepage: http://github.com/shvets/selenium_dsl
94
+ licenses: []
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ segments:
106
+ - 0
107
+ hash: -3260942171541288313
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 1.8.25
117
+ signing_key:
118
+ specification_version: 3
119
+ summary: Simple way to build Selenium code as DSL.
120
+ test_files:
121
+ - spec/access_wikipedia_spec.rb
122
+ - spec/spec_helper.rb