2
2
# rake android[common/web_context]
3
3
describe 'the web context' do
4
4
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
10
6
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 }
12
36
13
- set_context webview_context
14
- current_context . must_equal webview_context
37
+ # verify inspect within webview works
15
38
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' }
16
60
end
17
61
end
0 commit comments