rwebspec-webdriver 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/Rakefile +11 -12
  2. data/lib/rwebspec-webdriver/assert.rb +445 -0
  3. data/lib/{rwebspec → rwebspec-webdriver}/clickJSDialog.rb +0 -0
  4. data/lib/{rwebspec → rwebspec-webdriver}/context.rb +13 -11
  5. data/lib/rwebspec-webdriver/database_checker.rb +76 -0
  6. data/lib/rwebspec-webdriver/driver.rb +1011 -0
  7. data/lib/rwebspec-webdriver/element_locator.rb +89 -0
  8. data/lib/rwebspec-webdriver/load_test_helper.rb +174 -0
  9. data/lib/{rwebspec → rwebspec-webdriver}/matchers/contains_text.rb +0 -0
  10. data/lib/rwebspec-webdriver/popup.rb +149 -0
  11. data/lib/rwebspec-webdriver/rspec_helper.rb +101 -0
  12. data/lib/rwebspec-webdriver/test_script.rb +10 -0
  13. data/lib/rwebspec-webdriver/test_utils.rb +219 -0
  14. data/lib/rwebspec-webdriver/testwise_plugin.rb +85 -0
  15. data/lib/rwebspec-webdriver/using_pages.rb +51 -0
  16. data/lib/rwebspec-webdriver/web_browser.rb +744 -0
  17. data/lib/rwebspec-webdriver/web_page.rb +110 -0
  18. data/lib/rwebspec-webdriver/web_testcase.rb +40 -0
  19. data/lib/rwebspec-webdriver.rb +12 -12
  20. metadata +22 -22
  21. data/lib/rwebspec/assert.rb +0 -443
  22. data/lib/rwebspec/database_checker.rb +0 -74
  23. data/lib/rwebspec/driver.rb +0 -1009
  24. data/lib/rwebspec/element_locator.rb +0 -87
  25. data/lib/rwebspec/load_test_helper.rb +0 -172
  26. data/lib/rwebspec/popup.rb +0 -147
  27. data/lib/rwebspec/rspec_helper.rb +0 -99
  28. data/lib/rwebspec/test_script.rb +0 -8
  29. data/lib/rwebspec/test_utils.rb +0 -217
  30. data/lib/rwebspec/testwise_plugin.rb +0 -83
  31. data/lib/rwebspec/using_pages.rb +0 -49
  32. data/lib/rwebspec/web_browser.rb +0 -742
  33. data/lib/rwebspec/web_page.rb +0 -108
  34. data/lib/rwebspec/web_testcase.rb +0 -38
@@ -1,108 +0,0 @@
1
- #***********************************************************
2
- #* Copyright (c) 2006, Zhimin Zhan.
3
- #* Distributed open-source, see full license in MIT-LICENSE
4
- #***********************************************************
5
- require File.join(File.dirname(__FILE__), 'assert')
6
- require File.join(File.dirname(__FILE__), 'driver')
7
- require 'fileutils'
8
-
9
- module RWebSpec
10
-
11
- # WebPage (children of AbstractWebPage) encapsulates a real web page.
12
- # For example,
13
- # beginAt("/home")
14
- # @web_browser.clickLinkWithText("/login")
15
- # @web_browser.setFormElement("username", "sa")
16
- # Can be rewritten to
17
- # begin_at("/home")
18
- # home_page = HomePage.new
19
- # login_page = home_page.clickLoginLink
20
- # login_page.enterUserName("sa")
21
- #
22
- # So you only need change in LoingPage class if UI changes, which happen quite often.
23
- class AbstractWebPage
24
-
25
- include RWebSpec::Assert
26
- include RWebSpec::Driver
27
-
28
- # browser: passed to do assertion within the page
29
- # page_text: text used to identify the page, title will be the first candidate
30
- attr_accessor :page_specific_text
31
-
32
- def initialize(the_browser, page_specific_text = nil)
33
- @web_browser = the_browser
34
- @web_tester = the_browser
35
- @page_specific_text = page_specific_text
36
- begin
37
- snapshot if $ITEST2_DUMP_PAGE
38
- delay = $ITEST2_PAGE_DELAY
39
- sleep(delay)
40
- rescue => e
41
- end
42
- assert_on_page
43
- end
44
-
45
- # return the browser instance in page objects
46
- def browser
47
- @web_browser
48
- end
49
-
50
- # Assert is on current page
51
- # Example
52
- # home_page = HomePage.new("Welcome to iTest2")
53
- # ....
54
- # home_page.assert_on_page # will check the text 'Welcome to iTest2' still present on the page
55
- def assert_on_page()
56
- assert_text_present(@page_specific_text) if @page_specific_text
57
- end
58
-
59
- def assert_not_on_page()
60
- assert_text_not_present(@page_specific_text) if @page_specific_text
61
- end
62
-
63
- def dump(stream = nil)
64
- @web_browser.dump_response(stream)
65
- end
66
-
67
- # Page source (html)
68
- def source
69
- @web_browser.page_source
70
- end
71
- alias html source
72
-
73
- # return current page title
74
- def title
75
- @web_browser.page_title
76
- end
77
-
78
- # return current page text
79
- def text
80
- @web_browser.text
81
- end
82
-
83
- def url
84
- @web_browser.url
85
- end
86
-
87
- # TO validate
88
- def contains?(ary)
89
- return true if ary.nil?
90
- the_page_source = source
91
- found = false
92
- ary.each_line do |str|
93
- found ||= the_page_source.include?(str)
94
- end
95
- return found
96
- end
97
-
98
- # Will save current page source to a file
99
- # home_page = HomePage.new("Welcome to iTest2")
100
- # ...
101
- # home_page.snapshot() # => save to 20090830100102_HomePage.html
102
- def snapshot(replace_css = false)
103
- save_current_page(:filename => Time.now.strftime("%m%d%H%M%S") + "_" + self.class.name.gsub(" ", "") + ".html" )
104
- end
105
-
106
- end
107
-
108
- end
@@ -1,38 +0,0 @@
1
- #***********************************************************
2
- #* Copyright (c) 2006, Zhimin Zhan.
3
- #* Distributed open-source, see full license in MIT-LICENSE
4
- #***********************************************************
5
-
6
- # Deprecated, use RSpec syntax instead
7
-
8
- require 'test/unit'
9
- require File.join(File.dirname(__FILE__), 'assert')
10
- require File.join(File.dirname(__FILE__), 'driver')
11
-
12
- module RWebSpec
13
-
14
- class WebTestCase < Test::Unit::TestCase
15
- include RWebSpec::Driver
16
- include RWebSpec::Assert
17
- include RWebSpec::Utils
18
-
19
- attr_reader :web_tester
20
-
21
- def initialize(name=nil)
22
- super(name) if name
23
- @web_browser = WebBrowser.new
24
- end
25
-
26
- def default_test
27
- super unless (self.class == WebTestCase)
28
- end
29
-
30
- def open_browser(baseUrl, relativeUrl)
31
- context.base_url = baseUrl
32
- begin_at(relativeUrl)
33
- end
34
- alias open_ie open_browser
35
-
36
- end
37
-
38
- end