Skip to content

Commit 9838d6a

Browse files
Move context tests to web_context.rb
1 parent d6faefa commit 9838d6a

File tree

2 files changed

+52
-62
lines changed

2 files changed

+52
-62
lines changed

android_tests/lib/android/specs/common/device.rb

-54
Original file line numberDiff line numberDiff line change
@@ -33,60 +33,6 @@
3333
wait { current_activity.must_equal '.ApiDemos' }
3434
end
3535

36-
# appium's context support is broken on android
37-
38-
t 'available_contexts' do
39-
wait_true { available_contexts.include? 'NATIVE_APP' }
40-
end
41-
42-
t 'current_context' do
43-
wait { current_context.must_equal 'NATIVE_APP' }
44-
end
45-
46-
t 'set_context' do
47-
wait { scroll_to('Views').click }
48-
wait { scroll_to('WebView').click }
49-
50-
def undo_setcontext_nav
51-
back
52-
wait { find('WebView') }
53-
back
54-
wait { find'Views' }
55-
end
56-
57-
contexts = available_contexts
58-
webview_context = contexts.detect { |e| e.start_with?('WEBVIEW') }
59-
60-
if webview_context.nil?
61-
undo_setcontext_nav
62-
raise "No webview context found. contexts are: #{contexts}"
63-
end
64-
65-
wait { set_context webview_context }
66-
wait { current_context.must_equal webview_context }
67-
68-
wait { set_context 'NATIVE_APP' }
69-
wait { current_context.must_equal 'NATIVE_APP' }
70-
71-
undo_setcontext_nav
72-
end
73-
74-
t 'within_context' do
75-
$driver.within_context 'NATIVE_APP' do
76-
wait { current_context.must_equal 'NATIVE_APP' }
77-
end
78-
end
79-
80-
t 'switch_to_default_context' do
81-
wait do
82-
switch_to_default_context
83-
current_context.must_equal 'NATIVE_APP'
84-
end
85-
86-
wait { set_context 'NATIVE_APP' }
87-
wait { current_context.must_equal 'NATIVE_APP' }
88-
end
89-
9036
t 'app_strings' do
9137
wait_true { app_strings.has_key? 'activity_save_restore' }
9238
end

android_tests/lib/android/specs/common/web_context.rb

+52-8
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,60 @@
22
# rake android[common/web_context]
33
describe 'the web context' do
44

5-
t 'get_android_inspect' do
6-
scroll_to 'Views'
7-
last_text.click
8-
scroll_to 'WebView'
9-
last_text.click
5+
# appium's context support is broken on android
106

11-
webview_context = available_contexts.detect { |e| e.start_with?('WEBVIEW') }
7+
t 'available_contexts' do
8+
wait_true { available_contexts.include? 'NATIVE_APP' }
9+
end
10+
11+
t 'current_context' do
12+
wait { current_context.must_equal 'NATIVE_APP' }
13+
end
14+
15+
t 'set_context' do
16+
wait { scroll_to('Views').click }
17+
wait { scroll_to('WebView').click }
18+
19+
def undo_setcontext_nav
20+
back
21+
wait { find('WebView') }
22+
back
23+
wait { find 'Views' }
24+
end
25+
26+
contexts = available_contexts
27+
webview_context = contexts.detect { |e| e.start_with?('WEBVIEW') }
28+
29+
if webview_context.nil?
30+
undo_setcontext_nav
31+
raise "No webview context found. contexts are: #{contexts}"
32+
end
33+
34+
wait { set_context webview_context }
35+
wait { current_context.must_equal webview_context }
1236

13-
set_context webview_context
14-
current_context.must_equal webview_context
37+
# verify inspect within webview works
1538
get_android_inspect.split("\n").length.must_be :>=, 3
39+
40+
wait { set_context 'NATIVE_APP' }
41+
wait { current_context.must_equal 'NATIVE_APP' }
42+
43+
undo_setcontext_nav
44+
end
45+
46+
t 'within_context' do
47+
$driver.within_context 'NATIVE_APP' do
48+
wait { current_context.must_equal 'NATIVE_APP' }
49+
end
50+
end
51+
52+
t 'switch_to_default_context' do
53+
wait do
54+
switch_to_default_context
55+
current_context.must_equal 'NATIVE_APP'
56+
end
57+
58+
wait { set_context 'NATIVE_APP' }
59+
wait { current_context.must_equal 'NATIVE_APP' }
1660
end
1761
end

0 commit comments

Comments
 (0)