Skip to content

Commit cdaf1bc

Browse files
committed
add bidi test
1 parent 8b29538 commit cdaf1bc

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# frozen_string_literal: true
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
require 'test_helper'
16+
17+
# $ rake test:func:android TEST=test/functional/android/webdriver/create_session_test.rb
18+
class AppiumLibCoreTest
19+
module WebDriver
20+
class BidiTest < AppiumLibCoreTest::Function::TestCase
21+
def test_bidi
22+
caps = Caps.android
23+
caps[:capabilities]['webSocketUrl'] = true
24+
core = ::Appium::Core.for(caps)
25+
26+
driver = core.start_driver
27+
assert !driver.capabilities.nil?
28+
29+
log_entries = []
30+
31+
driver.bidi.send_cmd('session.subscribe', 'events': ['log.entryAdded'], 'contexts': ['NATIVE_APP'])
32+
subscribe_id = driver.bidi.add_callback('log.entryAdded') do |params|
33+
log_entries << params
34+
end
35+
36+
driver.page_source
37+
38+
driver.bidi.remove_callback('log.entryAdded', subscribe_id)
39+
driver.bidi.send_cmd('session.unsubscribe', 'events': ['log.entryAdded'], 'contexts': ['NATIVE_APP'])
40+
41+
driver&.quit
42+
end
43+
end
44+
end
45+
end

0 commit comments

Comments
 (0)