Skip to content

Incorrect calls to raise in set_implicit_wait_by_default #130

@tjjjwxzq

Description

@tjjjwxzq

This is a

  • [ X] Bug report
  • Question
  • Feature Request

Summary

I ran into an error trying to start Chrome on Android, where an exception was being thrown in set_implicit_wait_by_default in lib/appium_lib_core/driver.rb:231, but because of the malformed raise statement, an unhelpful TypeError: exception class/object expected was raised instead

Environment

  • ruby_lib_core version: 1.9.0
  • Mobile platform/version/device under test: Android 8.0, Chrome

Actual behaviour and steps to reproduce

Raised TypeError: exception class/object expected when trying to initialize driver to launch Chrome on Android. (Will not enumerate full reproduction steps here, as the base error is raised by the Appium server when trying to set the implicit wait probably for other reasons. However the way this error is handled and re-raised inside set_implicit_wait_by_default is incorrect.

The raise statements should be fixed to put the error message after the class:

 def set_implicit_wait_by_default(wait)
        @driver.manage.timeouts.implicit_wait = wait
      rescue ::Selenium::WebDriver::Error::UnknownError => e
        unless e.message.include?('The operation requested is not yet implemented')
         # This is incorrect
          # raise e.message, ::Appium::Core::Error::ServerError
          # Error class should come first
           raise ::Appium::Core::Error::ServerError, e.message
        end

        Appium::Logger.debug(e.message)
        {}
      rescue ::Selenium::WebDriver::Error::WebDriverError => e
        # FIXME: Temporary rescue until Appium support W3C's implicit wait
        # https://github.com/jlipps/simple-wd-spec#set-timeouts
        unless e.message.include?('Parameters were incorrect. We wanted {"required":["type","ms"]} and you sent ["implicit"]')
         # same here
          # raise e.message, ::Appium::Core::Error::ServerError
           raise ::Appium::Core::Error::ServerError, e.message
        end

        Appium::Logger.debug(e.message)
        {}
      end

Expected behaviour

Should raise the actual error returned by the Appium server

Link to Appium/Ruby logs

Create a GIST which is a paste of your full Appium logs, and link them here.

Any additional comments

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions