iemodal 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/ChangeLog +5 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +18 -0
- data/Rakefile +21 -0
- data/cucumber.yml +5 -0
- data/features/html/modal.html +17 -0
- data/features/html/modal_1.html +38 -0
- data/features/html/modal_2.html +27 -0
- data/features/modal_dialog.feature +15 -0
- data/features/step_definitions/modal_dialog_steps.rb +66 -0
- data/features/support/env.rb +20 -0
- data/features/support/url_helper.rb +15 -0
- data/iemodal.gemspec +26 -0
- data/lib/iemodal/version.rb +3 -0
- data/lib/iemodal.rb +68 -0
- metadata +109 -0
data/ChangeLog
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Jeff Morgan
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# iemodal
|
2
|
+
|
3
|
+
A gem to allow interaction with Internet Explorer modal dialogs. This gem must be used
|
4
|
+
with the page-object gem. You must simply include the iemodal module after you include
|
5
|
+
the page-object module.
|
6
|
+
|
7
|
+
class MyPage
|
8
|
+
include PageObject
|
9
|
+
include IEModal
|
10
|
+
end
|
11
|
+
|
12
|
+
## Known Issues
|
13
|
+
|
14
|
+
See [http://github.com/cheezy/page-object/issues](http://github.com/cheezy/iemodal/issues)
|
15
|
+
|
16
|
+
## Copyright
|
17
|
+
|
18
|
+
Copyright (c) 2011 Jeffrey S. Morgan. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require 'cucumber'
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
|
6
|
+
require "bundler/gem_tasks"
|
7
|
+
|
8
|
+
namespace :features do
|
9
|
+
Cucumber::Rake::Task.new(:watir, "Run features with watir-webdriver") do |t|
|
10
|
+
t.profile = 'watir'
|
11
|
+
end
|
12
|
+
|
13
|
+
Cucumber::Rake::Task.new(:selenium, "Run features with selenium-webdriver") do |t|
|
14
|
+
t.profile = 'selenium'
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Run all features'
|
18
|
+
task :all => [:watir, :selenium]
|
19
|
+
end
|
20
|
+
|
21
|
+
|
data/cucumber.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>modal dialog test page</title>
|
4
|
+
</head>
|
5
|
+
<body>
|
6
|
+
|
7
|
+
<script type="text/javascript">
|
8
|
+
function modal() {
|
9
|
+
var retValue = window.showModalDialog(
|
10
|
+
"modal_1.html", self,
|
11
|
+
"status:no;resizable:Yes;help:no;maximize:no;minimize:no;scrollbars:no;");
|
12
|
+
}
|
13
|
+
</script>
|
14
|
+
|
15
|
+
<input id=launch_modal_button type=button onclick='return modal();' value="Launch a modal" />
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<html>
|
2
|
+
|
3
|
+
<head>
|
4
|
+
<title>Modal 1</title>
|
5
|
+
|
6
|
+
<script>
|
7
|
+
function delay_action(other_function) {
|
8
|
+
setTimeout(other_function, 3000);
|
9
|
+
}
|
10
|
+
|
11
|
+
function close_window() {
|
12
|
+
window.returnValue = 22
|
13
|
+
window.close()
|
14
|
+
}
|
15
|
+
|
16
|
+
function modal1() {
|
17
|
+
var retValue = window.showModalDialog(
|
18
|
+
"modal_2.html", self,
|
19
|
+
"status:no;resizable:Yes;help:no;maximize:no;minimize:no;scrollbars:no;");
|
20
|
+
}
|
21
|
+
|
22
|
+
</script>
|
23
|
+
|
24
|
+
</head>
|
25
|
+
|
26
|
+
<body>
|
27
|
+
|
28
|
+
<h2>Modal 1</h2>
|
29
|
+
|
30
|
+
<h3>Close buttons</h3>
|
31
|
+
<input id=close_window type=button onclick="close_window()" value="Close window"/>
|
32
|
+
<input id=delayed_close type=button onclick="delay_action('close_window()')" value="Close window with delay" />
|
33
|
+
|
34
|
+
<h3>Nested modal</h3>
|
35
|
+
<input id=launch_modal_button type=button onclick='return modal1();' value="Launch another modal"/>
|
36
|
+
|
37
|
+
</body>
|
38
|
+
</html>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<html>
|
2
|
+
|
3
|
+
<head>
|
4
|
+
<title>Modal 2</title>
|
5
|
+
|
6
|
+
<script>
|
7
|
+
function delay_action(other_function) {
|
8
|
+
setTimeout(other_function, 3000);
|
9
|
+
}
|
10
|
+
|
11
|
+
function close_window() {
|
12
|
+
self.close()
|
13
|
+
}
|
14
|
+
</script>
|
15
|
+
|
16
|
+
</head>
|
17
|
+
|
18
|
+
<body>
|
19
|
+
|
20
|
+
<h2>Modal 2</h2>
|
21
|
+
|
22
|
+
<h3>Close buttons</h3>
|
23
|
+
<input id=close_window2 type="button" onclick="close_window()" value="Close window"/>
|
24
|
+
<input id=delayed_close2 type=button onclick="delay_action('close_window()')" value="Close window with delay" />
|
25
|
+
|
26
|
+
</body>
|
27
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Feature: handing modal dialogs
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I am on the modal page
|
5
|
+
|
6
|
+
|
7
|
+
Scenario: Interacting with a modal dialog
|
8
|
+
When I open a modal dialog
|
9
|
+
Then I should be able to close the modal
|
10
|
+
|
11
|
+
Scenario: Nested modal dialogs
|
12
|
+
When I open a modal dialog
|
13
|
+
And I open another modal dialog from that one
|
14
|
+
Then I should be able to close both modals
|
15
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
class ModalPage
|
2
|
+
include PageObject
|
3
|
+
include IEModal
|
4
|
+
|
5
|
+
page_url UrlHelper.modal
|
6
|
+
button(:launch_modal, :id => 'launch_modal_button')
|
7
|
+
end
|
8
|
+
|
9
|
+
class ModalDialog
|
10
|
+
include PageObject
|
11
|
+
include IEModal
|
12
|
+
|
13
|
+
button(:close_window, :id => 'close_window')
|
14
|
+
button(:close_window_with_delay, :id => 'delayed_close')
|
15
|
+
button(:launch_another_modal, :id => 'launch_modal_button')
|
16
|
+
end
|
17
|
+
|
18
|
+
class AnotherModalDialog
|
19
|
+
include PageObject
|
20
|
+
include IEModal
|
21
|
+
|
22
|
+
button(:close_window, :id => 'close_window2')
|
23
|
+
button(:close_window_with_delay, :id => 'delayed_close2')
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
Given /^I am on the modal page$/ do
|
28
|
+
visit_page ModalPage
|
29
|
+
end
|
30
|
+
|
31
|
+
When /^I open a modal dialog$/ do
|
32
|
+
on_page ModalPage do |page|
|
33
|
+
page.modal_dialog do
|
34
|
+
page.launch_modal
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Then /^I should be able to close the modal$/ do
|
40
|
+
on_page ModalDialog do |page|
|
41
|
+
page.close_window
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
When /^I open another modal dialog from that one$/ do
|
46
|
+
on_page ModalDialog do |page|
|
47
|
+
page.modal_dialog do
|
48
|
+
page.launch_another_modal
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
Then /^I should be able to close both modals$/ do
|
54
|
+
on_page AnotherModalDialog do |page|
|
55
|
+
page.close_window
|
56
|
+
end
|
57
|
+
|
58
|
+
on_page ModalDialog do |page|
|
59
|
+
page.attach_to_window(:title => 'Modal 1')
|
60
|
+
page.close_window
|
61
|
+
end
|
62
|
+
|
63
|
+
on_page ModalPage do |page|
|
64
|
+
page.attach_to_window(:title => 'modal dialog test page')
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../../', 'lib'))
|
2
|
+
|
3
|
+
require 'iemodal'
|
4
|
+
require 'rspec/expectations'
|
5
|
+
require 'watir-webdriver'
|
6
|
+
require 'selenium-webdriver'
|
7
|
+
require 'page-object'
|
8
|
+
require 'page-object/page_factory'
|
9
|
+
|
10
|
+
World(PageObject::PageFactory)
|
11
|
+
|
12
|
+
|
13
|
+
Before do
|
14
|
+
@browser = Watir::Browser.new :ie if ENV['DRIVER'] == 'WATIR'
|
15
|
+
@browser = Selenium::WebDriver.for :ie if ENV['DRIVER'] == 'SELENIUM'
|
16
|
+
end
|
17
|
+
|
18
|
+
After do
|
19
|
+
# @browser.close
|
20
|
+
end
|
data/iemodal.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "iemodal/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "iemodal"
|
7
|
+
s.version = IEModal::VERSION
|
8
|
+
s.authors = ["Jeffrey S. Morgan"]
|
9
|
+
s.email = ["jeff.morgan@leandog.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Makes it possible to interact with modal dialogs in Internet Explorer}
|
12
|
+
s.description = %q{Makes it possible to interact with modal dialogs in Internet Explorer}
|
13
|
+
|
14
|
+
s.rubyforge_project = "iemodal"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency 'page-object'
|
22
|
+
|
23
|
+
|
24
|
+
s.add_development_dependency 'rspec', '>= 2.6.0'
|
25
|
+
s.add_development_dependency 'cucumber', '>= 1.0.0'
|
26
|
+
end
|
data/lib/iemodal.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'iemodal/version'
|
2
|
+
require 'page-object'
|
3
|
+
require 'watir-webdriver'
|
4
|
+
require 'selenium-webdriver'
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
module IEModal
|
8
|
+
|
9
|
+
def self.included(cls)
|
10
|
+
fail("This module only works with PageObject") unless cls.instance_methods.include? :modal_dialog
|
11
|
+
define_method("modal_dialog") do |&block|
|
12
|
+
return iemodal_watir_modal_dialog(&block) if is_ie_watir_webdriver
|
13
|
+
return iemodal_selenium_modal_dialog(&block) if is_ie_selenium_webdriver
|
14
|
+
return super &block
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def iemodal_watir_modal_dialog(&block)
|
19
|
+
handle_modal_dialog(browser.wd, &block)
|
20
|
+
end
|
21
|
+
|
22
|
+
def iemodal_selenium_modal_dialog(&block)
|
23
|
+
handle_modal_dialog(browser, &block)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def handle_modal_dialog(driver, &block)
|
29
|
+
original_handles = driver.window_handles
|
30
|
+
yield if block_given?
|
31
|
+
handles = wait_for_new_handle(original_handles, driver)
|
32
|
+
modal = (handles - original_handles).first
|
33
|
+
driver.switch_to.window modal
|
34
|
+
end
|
35
|
+
|
36
|
+
def wait_for_new_handle(original_handles, driver)
|
37
|
+
handles = nil
|
38
|
+
wait = Selenium::WebDriver::Wait.new
|
39
|
+
wait.until do
|
40
|
+
handles = driver.window_handles
|
41
|
+
handles.size == original_handles.size + 1
|
42
|
+
end
|
43
|
+
handles
|
44
|
+
end
|
45
|
+
|
46
|
+
def is_ie_watir_webdriver
|
47
|
+
return (is_watir and is_ie(@browser.wd.instance_variable_get "@bridge"))
|
48
|
+
end
|
49
|
+
|
50
|
+
def is_ie_selenium_webdriver
|
51
|
+
return (is_selenium and is_ie(@browser.instance_variable_get "@bridge"))
|
52
|
+
end
|
53
|
+
|
54
|
+
def is_watir
|
55
|
+
return @browser.is_a? Watir::Browser
|
56
|
+
end
|
57
|
+
|
58
|
+
def is_selenium
|
59
|
+
@browser.is_a? Selenium::WebDriver::Driver
|
60
|
+
end
|
61
|
+
|
62
|
+
def is_ie(bridge)
|
63
|
+
bridge.is_a? Selenium::WebDriver::IE::Bridge
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: iemodal
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.2
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jeffrey S. Morgan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-09-20 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: page-object
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rspec
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 2.6.0
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: cucumber
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.0.0
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id003
|
48
|
+
description: Makes it possible to interact with modal dialogs in Internet Explorer
|
49
|
+
email:
|
50
|
+
- jeff.morgan@leandog.com
|
51
|
+
executables: []
|
52
|
+
|
53
|
+
extensions: []
|
54
|
+
|
55
|
+
extra_rdoc_files: []
|
56
|
+
|
57
|
+
files:
|
58
|
+
- .gitignore
|
59
|
+
- ChangeLog
|
60
|
+
- Gemfile
|
61
|
+
- LICENSE
|
62
|
+
- README.md
|
63
|
+
- Rakefile
|
64
|
+
- cucumber.yml
|
65
|
+
- features/html/modal.html
|
66
|
+
- features/html/modal_1.html
|
67
|
+
- features/html/modal_2.html
|
68
|
+
- features/modal_dialog.feature
|
69
|
+
- features/step_definitions/modal_dialog_steps.rb
|
70
|
+
- features/support/env.rb
|
71
|
+
- features/support/url_helper.rb
|
72
|
+
- iemodal.gemspec
|
73
|
+
- lib/iemodal.rb
|
74
|
+
- lib/iemodal/version.rb
|
75
|
+
homepage: ""
|
76
|
+
licenses: []
|
77
|
+
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: "0"
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: "0"
|
95
|
+
requirements: []
|
96
|
+
|
97
|
+
rubyforge_project: iemodal
|
98
|
+
rubygems_version: 1.8.10
|
99
|
+
signing_key:
|
100
|
+
specification_version: 3
|
101
|
+
summary: Makes it possible to interact with modal dialogs in Internet Explorer
|
102
|
+
test_files:
|
103
|
+
- features/html/modal.html
|
104
|
+
- features/html/modal_1.html
|
105
|
+
- features/html/modal_2.html
|
106
|
+
- features/modal_dialog.feature
|
107
|
+
- features/step_definitions/modal_dialog_steps.rb
|
108
|
+
- features/support/env.rb
|
109
|
+
- features/support/url_helper.rb
|