rwebunit 0.9.4 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,64 @@
1
+ require 'rubygems'
2
+ require 'firewatir'
3
+
4
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib/rwebunit")
5
+ $:.unshift File.dirname(__FILE__)
6
+
7
+ require "test_utils"
8
+ require "web_page"
9
+ require "assert"
10
+ require "itest_plugin"
11
+ require "web_browser"
12
+ require "driver"
13
+ require "context"
14
+ require "driver"
15
+ require "rspec_helper"
16
+ require 'test/unit'
17
+ require 'setup'
18
+
19
+ class TestDriver < Test::Unit::TestCase
20
+ include RWebUnit::Utils
21
+ include RWebUnit::RSpecHelper
22
+
23
+ def setup
24
+ @web_browser = $web_browser
25
+ end
26
+
27
+ def teardown
28
+ end
29
+
30
+ def test_assert_text
31
+ assert_text_present("iTest2/Watir Recorder Test Page")
32
+ assert_text_not_present("iTest3/Watir Recorder Test Page")
33
+ end
34
+
35
+ def test_assert_link
36
+ assert_link_present_with_text("iTest2 with Id")
37
+ assert_link_not_present_with_text("iTest2 with id")
38
+ assert_link_not_present_with_text("XX")
39
+ end
40
+
41
+ def test_checkbox
42
+ assert_checkbox_not_selected("checkbox1")
43
+ check_checkbox("checkbox1")
44
+ assert_checkbox_selected("checkbox1")
45
+ uncheck_checkbox("checkbox1")
46
+ assert_checkbox_not_selected("checkbox1")
47
+ end
48
+
49
+ def test_radiobutton
50
+ assert_radio_option_present("os", "Linux")
51
+ assert_radio_option_present("os","Apple")
52
+ assert_radio_option_not_present("os","Windows")
53
+ click_radio_option("os", "Linux")
54
+ assert_radio_option_selected("os", "Linux")
55
+ end
56
+
57
+ def test_button
58
+ assert_button_present("login-btn")
59
+ assert_button_not_present("login-Btn")
60
+ assert_button_present_with_text("Login")
61
+ assert_button_not_present_with_text("login")
62
+ end
63
+
64
+ end
data/test/test_driver.rb CHANGED
@@ -1,15 +1,26 @@
1
+ require 'firewatir'
2
+
1
3
  $:.unshift File.join(File.dirname(__FILE__), "..", "lib/rwebunit")
2
4
  $:.unshift File.dirname(__FILE__)
3
5
 
4
- require "driver.rb"
5
- require "web_tester.rb"
6
+ require "test_utils"
7
+ require "web_page"
8
+ require "assert"
9
+ require "itest_plugin"
10
+ require "web_browser"
11
+ require "driver"
12
+ require "context"
13
+ require "driver"
14
+ require "rspec_helper"
6
15
  require 'test/unit'
16
+ require 'setup'
17
+ require 'mock_page'
7
18
 
8
19
  class TestDriver < Test::Unit::TestCase
9
20
  include RWebUnit::Driver
10
21
 
11
22
  def setup
12
- @web_tester = "dummy"
23
+ @web_browser = $web_browser
13
24
  end
14
25
 
15
26
  def teardown
@@ -20,7 +31,7 @@ class TestDriver < Test::Unit::TestCase
20
31
  end
21
32
 
22
33
  def test_expect_page
23
- new_page = expect_page String
34
+ new_page = expect_page MockPage
24
35
  assert_equal("dummy", new_page)
25
36
  end
26
37
 
@@ -32,8 +43,15 @@ class TestDriver < Test::Unit::TestCase
32
43
  end
33
44
  assert_equal(["0", "1"], page)
34
45
  end
35
-
46
+
36
47
  def test_shall_not_allow
37
48
  shall_not_allow {1 / 0}
38
49
  end
50
+
51
+ def test_symbol_to_sequence
52
+ assert_equal 1, symbol_to_sequence(:first)
53
+ assert_equal 2, symbol_to_sequence(:second)
54
+ assert_equal 11, symbol_to_sequence(11)
55
+ end
56
+
39
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rwebunit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zhimin Zhan
@@ -9,7 +9,7 @@ autorequire: rwebunit
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-20 00:00:00 +10:00
12
+ date: 2009-01-24 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -18,10 +18,20 @@ dependencies:
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - ">="
21
+ - - "="
22
22
  - !ruby/object:Gem::Version
23
23
  version: 1.1.4
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: commonwatir
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.6.2
34
+ version:
25
35
  description:
26
36
  email: zhimin@agileway.net
27
37
  executables: []
@@ -38,25 +48,25 @@ files:
38
48
  - lib/rspec_extensions.rb
39
49
  - lib/rwebunit
40
50
  - lib/rwebunit/assert.rb
51
+ - lib/rwebunit/clickJSDialog.rb
41
52
  - lib/rwebunit/context.rb
42
53
  - lib/rwebunit/driver.rb
54
+ - lib/rwebunit/itest_plugin.rb
55
+ - lib/rwebunit/matchers
56
+ - lib/rwebunit/matchers/contains_text.rb
43
57
  - lib/rwebunit/rspec_helper.rb
44
58
  - lib/rwebunit/test_utils.rb
59
+ - lib/rwebunit/web_browser.rb
45
60
  - lib/rwebunit/web_page.rb
46
61
  - lib/rwebunit/web_testcase.rb
47
- - lib/rwebunit/web_tester.rb
48
62
  - lib/rwebunit.rb
63
+ - lib/watir_extensions.rb
64
+ - test/mock_page.rb
65
+ - test/setup.rb
66
+ - test/test.html
67
+ - test/test_assert.rb
49
68
  - test/test_driver.rb
50
69
  - test/test_test_utils.rb
51
- - sample/kangxi_home_webtest.rb
52
- - sample/kangxi_httpcaller_webtest.rb
53
- - sample/kangxi_pages.rb
54
- - sample/kangxi_xml_formatter_webtest.rb
55
- - sample/README.txt
56
- - sample/rwebunit_home_testcase.rb
57
- - sample/sample_rwebunit_test.rb
58
- - sample/sample_rwebunit_testcase.rb
59
- - sample/sample_watir_test.rb
60
70
  - docs/html
61
71
  - docs/html/index.html
62
72
  has_rdoc: true
@@ -81,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
91
  requirements:
82
92
  - none
83
93
  rubyforge_project: rwebunit
84
- rubygems_version: 1.2.0
94
+ rubygems_version: 1.3.1
85
95
  signing_key:
86
96
  specification_version: 2
87
97
  summary: An wrap of WATIR/FireWatir for functional testing of web applications
data/sample/README.txt DELETED
@@ -1,21 +0,0 @@
1
-
2
- Sample tests
3
- ============
4
-
5
- 1. Comparing Watir and RWebUnit:
6
- sample_rwebunit_test.rb
7
- sample_watir_test.rb
8
-
9
- 2. Comparing RWebUnit and JWebUnit:
10
- sample_rwebunit_testcase.rb
11
-
12
- 3. A more complex single web test
13
- rwebunit_home_test.rb
14
-
15
- 4. An organised set of web tets against a web application, using TestCase + TestPage design:
16
- kangxi_pages.rb
17
- kangxi_httpcaller_webtest.rb
18
- kangxi_xml_formatter_webtest.rb
19
- kangxi_home_webtest.rb
20
-
21
- Note: Kangxi is a rails web application.
@@ -1,37 +0,0 @@
1
- #$:.unshift File.join(File.dirname(__FILE__), "..", "lib/rwebunit")
2
-
3
- require "rwebunit"
4
-
5
- $:.unshift File.dirname(__FILE__)
6
- require "kangxi_pages.rb"
7
-
8
- class TestKangxiHome < RWebUnit::WebTestCase
9
-
10
- def initialize(name)
11
- super(name)
12
- end
13
-
14
- def setup
15
- super
16
- getTestContext().base_url = "http://localhost:3721"
17
- beginAt("/home")
18
- end
19
-
20
- def teardown
21
- super
22
- closeBrowser()
23
- end
24
-
25
- def test_homepage_exists()
26
- kangxi_homepage = KangxiHomePage.new(@web_tester, "Welcome")
27
- end
28
-
29
- def test_all_links_exist
30
- kangxi_homepage = KangxiHomePage.new(@web_tester, "Welcome")
31
- kangxi_homepage.assertTheListLinkPresent()
32
- kangxi_homepage.assertDashboardLinkPresent
33
- kangxi_homepage.assertTestCenterLinkPresent
34
- kangxi_homepage.assertTestWebServiceLinkPresent
35
- end
36
-
37
- end
@@ -1,33 +0,0 @@
1
- #$:.unshift File.join(File.dirname(__FILE__), "..", "lib/rwebunit")
2
-
3
- require "rwebunit"
4
-
5
- $:.unshift File.dirname(__FILE__)
6
- require "kangxi_pages.rb"
7
-
8
- class TestHttpCaller < RWebUnit::WebTestCase
9
-
10
- def initialize(name)
11
- super(name)
12
- end
13
-
14
- def setup
15
- super
16
- getTestContext().base_url = "http://localhost:3721"
17
- beginAt("/http")
18
- end
19
-
20
- def teardown
21
- super
22
- closeBrowser()
23
- end
24
-
25
- def test_can_display()
26
- kangxi_httpcaller_page = KangxiHttpCallerPage.new(@web_tester)
27
- @web_tester.assertOptionValuePresent("method", "POST")
28
- @web_tester.assertOptionValuePresent("method", "GET")
29
-
30
- end
31
-
32
-
33
- end
@@ -1,62 +0,0 @@
1
- require "rwebunit"
2
-
3
- class KangxiHomePage < RWebUnit::AbstractWebPage
4
-
5
- def initialize(browser, title)
6
- super(browser, title)
7
- end
8
-
9
- def assertTheListLinkPresent
10
- @browser.assertLinkPresentWithText('The List')
11
- end
12
-
13
- def assertDashboardLinkPresent
14
- @browser.assertLinkPresentWithText('Dashboard')
15
- end
16
-
17
- def assertTestCenterLinkPresent
18
- @browser.assertLinkPresentWithText('Test center')
19
- end
20
-
21
- def assertTestWebServiceLinkPresent
22
- @browser.assertLinkPresentWithText('Test web service')
23
- end
24
-
25
- def clickXMLFormatterLink
26
- @browser.clickLinkWithText("XML Formatter")
27
- KangxiXMLFormatterPage.new(@browser, "Format XML")
28
- end
29
-
30
- end
31
-
32
- class KangxiXMLFormatterPage < RWebUnit::AbstractWebPage
33
-
34
- def initialize(browser, title)
35
- super(browser, title)
36
- end
37
-
38
- def clickFillExampleLink
39
- @browser.clickLinkWithText("Fill example")
40
- end
41
-
42
- def enterXml(inputXml)
43
- @browser.enterText("inputText", inputXml)
44
- end
45
-
46
- def clickFormat
47
- @browser.clickButtonWithValue("Format")
48
- end
49
-
50
- end
51
-
52
- class KangxiHttpCallerPage < RWebUnit::AbstractWebPage
53
- def initialize(browser)
54
- super(browser,"Http Caller")
55
- end
56
- end
57
-
58
- class KangxiCookbookPage < RWebUnit::AbstractWebPage
59
- def initialize(browser)
60
- super(browser,"code recipes")
61
- end
62
- end
@@ -1,44 +0,0 @@
1
- #$:.unshift File.join(File.dirname(__FILE__), "..", "lib/rwebunit")
2
-
3
- require "rwebunit"
4
-
5
- $:.unshift File.dirname(__FILE__)
6
- require "kangxi_pages.rb"
7
-
8
- class TestXmlFormatter < RWebUnit::WebTestCase
9
-
10
- def initialize(name)
11
- super(name)
12
- end
13
-
14
- def setup
15
- super
16
- getTestContext().base_url = "http://localhost:3721"
17
- beginAt("/home")
18
- kangxi_homepage = KangxiHomePage.new(@web_tester, "Welcome")
19
- @kangxi_xmlformatter_page = kangxi_homepage.clickXMLFormatterLink
20
- end
21
-
22
- def teardown
23
- super
24
- closeBrowser()
25
- end
26
-
27
- def test_can_invoke_format
28
- @kangxi_xmlformatter_page.enterXml("<name><first>James</first><last>Bond</last></name>")
29
- @kangxi_xmlformatter_page.clickFormat
30
- end
31
-
32
- def test_format_sample_xml
33
- @kangxi_xmlformatter_page.clickFillExampleLink
34
- @web_tester.assertElementNotPresent("formatted_xml")
35
- @kangxi_xmlformatter_page.submit
36
- @web_tester.assertElementPresent("formatted_xml")
37
- end
38
-
39
- def test_can_call_utils
40
- @kangxi_xmlformatter_page.enterXml("<date><now>" + getToday + "</now></date>")
41
- @kangxi_xmlformatter_page.clickFormat
42
- end
43
-
44
- end
@@ -1,22 +0,0 @@
1
- # the same test used in jWebUnit home page written in rWebUnit
2
- require 'rwebunit'
3
-
4
- class TestRWebUnitHome < RWebUnit::WebTestCase
5
-
6
- def initialize(name)
7
- super(name)
8
- end
9
-
10
- def setup
11
- getTestContext().setBaseUrl("http://www.zhimin.com")
12
- beginAt("/")
13
- end
14
-
15
- def test_rdoc()
16
- setFormElement("q", "httpunit")
17
- submit("btnG")
18
- clickLinkWithText("HttpUnit Home")
19
- assertTitleEquals("HttpUnit Home")
20
- assertLinkPresentWithText("User's Manual")
21
- end
22
- end
@@ -1,15 +0,0 @@
1
- # a sample rwebunit test check HttpUnit home page
2
- require 'rwebunit'
3
-
4
- class RWebUnitSearchExample < RWebUnit::WebTestCase
5
-
6
- def test_search()
7
- getTestContext().base_url = "http://www.google.com"
8
- beginAt("/")
9
- setFormElement("q", "httpunit")
10
- clickButtonWithCaption("Google Search")
11
- clickLinkWithText("HttpUnit Home")
12
- assertTitleEquals("HttpUnit Home")
13
- assertLinkPresentWithText("User's Manual")
14
- end
15
- end