Skip to content

Commit cef57da

Browse files
committed
add size check in page source for easy regression
1 parent 633cc0f commit cef57da

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

test/functional/android/webdriver/device_test.rb

+28-1
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,36 @@ def test_set_immediate_value
3939
end
4040

4141
def test_page_source
42+
require 'rexml/document'
43+
44+
expected = %w(
45+
hierarchy
46+
android.widget.FrameLayout
47+
android.view.ViewGroup
48+
android.widget.FrameLayout
49+
android.view.ViewGroup
50+
android.widget.TextView
51+
android.widget.FrameLayout
52+
android.widget.ListView
53+
android.widget.TextView
54+
android.widget.TextView
55+
android.widget.TextView
56+
android.widget.TextView
57+
android.widget.TextView
58+
android.widget.TextView
59+
android.widget.TextView
60+
android.widget.TextView
61+
android.widget.TextView
62+
android.widget.TextView
63+
android.widget.TextView
64+
android.widget.TextView
65+
)
66+
4267
s_source = @driver.page_source
68+
xml = REXML::Document.new s_source
4369

44-
assert s_source.include?('o.appium.android.apis')
70+
assert s_source.include?('io.appium.android.apis')
71+
assert_equal expected, xml[1].elements.each('//*'){ |v| v }.map{ |v| v.name }
4572
end
4673

4774
# def test_location

test/functional/ios/webdriver/device_test.rb

+6
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,22 @@ def by_predicate(value)
4848

4949
def test_page_source
5050
require 'json'
51+
require 'rexml/document'
52+
5153
response = Net::HTTP.get(URI('http://localhost:8100/source'))
5254
source = JSON.parse(response)['value']
55+
xml = REXML::Document.new source
5356

5457
assert !source.include?('AppiumAUT')
5558
assert source.include?('XCUIElementTypeApplication type')
59+
assert xml[2].elements.each('//*'){ |v| v }.map{ |v| v.name } == 77
5660

5761
s_source = @@driver.page_source
62+
s_xml = REXML::Document.new s_source
5863

5964
assert s_source.include?('AppiumAUT')
6065
assert s_source.include?('XCUIElementTypeApplication type')
66+
assert s_xml[2].elements.each('//*'){ |v| v }.map{ |v| v.name } == 81
6167
end
6268

6369
def test_location

0 commit comments

Comments
 (0)