android_tests/lib/android/specs/driver.rb in appium_lib-9.0.0 vs android_tests/lib/android/specs/driver.rb in appium_lib-9.1.0

- old
+ new

@@ -29,17 +29,19 @@ end # Only used for Sauce Labs t 'verify all attributes' do 2.times { set_wait 1 } # must set twice to validate last_waits - actual = driver_attributes - actual[:caps][:app] = File.basename actual[:caps][:app] - expected = { caps: { platformName: 'android', - app: 'api.apk', - appPackage: 'io.appium.android.apis', - appActivity: '.ApiDemos', - deviceName: 'Nexus 7' }, + actual = driver_attributes + caps_app_for_teardown = actual[:caps][:app] + actual[:caps][:app] = File.basename actual[:caps][:app] + expected_caps = ::Appium::Driver::Capabilities.init_caps_for_appium(platformName: 'Android', + app: 'api.apk', + appPackage: 'io.appium.android.apis', + appActivity: '.ApiDemos', + deviceName: 'Nexus 7') + expected = { caps: expected_caps, custom_url: false, export_session: false, default_wait: 1, last_waits: [1, 1], sauce_username: nil, @@ -50,16 +52,22 @@ listener: nil } if actual != expected diff = HashDiff.diff expected, actual diff = "diff (expected, actual):\n#{diff}" + + actual[:caps][:app] = caps_app_for_teardown # example: # change :ios in expected to match 'ios' in actual # [["~", "caps.platformName", :ios, "ios"]] message = "\n\nactual:\n\n: #{actual.ai}expected:\n\n#{expected.ai}\n\n#{diff}" - fail message + raise message end + + actual_selenium_caps = actual[:caps][:platformName] + actual_selenium_caps.must_equal 'Android' + actual[:caps][:app] = caps_app_for_teardown end end describe 'Appium::Driver' do t '$driver.class' do @@ -147,21 +155,21 @@ # screenshot # this is slow and already tested by Appium # driver_quit # tested by restart # start_driver # tested by restart # no_wait # posts value to server, it's not stored locally # set_wait # posts value to server, it's not stored locally - # execute_script # 'mobile: ' is deprecated and plain executeScript unsupported + # execute_script # 'mobile: ' is deprecated and plain execute_script unsupported t 'default_wait' do set_wait 1 default_wait.must_equal 1 end # returns true unless an error is raised t 'exists' do exists(0, 0) { true }.must_equal true - exists(0, 0) { fail 'error' }.must_equal false + exists(0, 0) { raise 'error' }.must_equal false end # any elements t 'find_elements' do wait do @@ -179,10 +187,10 @@ # simple integration sanity test to check for unexpected exceptions t 'set_location' do begin set_location latitude: 55, longitude: -72, altitude: 33 rescue Selenium::WebDriver::Error::UnknownError => e - # on android this method is expected to fail with this message when running + # on android this method is expected to raise with this message when running # on a regular device, or on genymotion. # error could be many messages, including: # ERROR running Appium command: port should be a number or string # ERROR running Appium command: port should be > 0 and < 65536 raise unless e.message.include?('ERROR running Appium command: port should be')