appium/ruby_lib

Appium, Ruby : promote_appium_methods call fails with error "`hide_keyboard' not defined ", Appium Lib 12.0.1

maheshchaudharCoupa opened this issue · 11 comments

I have upgraded the appium_lib gem with version 12.0.1 but "promote_appium_methods" is getting failed with below error.
Same code works perfectly with appium lib : 11.2.0.

Also, documentation link is not accessible,

  1. https://www.rubydoc.info/github/appium/ruby_lib_core.

NameError:
method hide_keyboard' not defined in #<Object:0x00007ff16f923a20> # /Users/maheshchaudhar/.rvm/gems/ruby-2.7.4/gems/appium_lib-12.0.1/lib/appium_lib/appium.rb:211:in remove_method'
# /Users/maheshchaudhar/.rvm/gems/ruby-2.7.4/gems/appium_lib-12.0.1/lib/appium_lib/appium.rb:211:in block (3 levels) in promote_appium_methods' # /Users/maheshchaudhar/.rvm/gems/ruby-2.7.4/gems/appium_lib-12.0.1/lib/appium_lib/appium.rb:204:in class_eval'
# /Users/maheshchaudhar/.rvm/gems/ruby-2.7.4/gems/appium_lib-12.0.1/lib/appium_lib/appium.rb:204:in block (2 levels) in promote_appium_methods' # /Users/maheshchaudhar/.rvm/gems/ruby-2.7.4/gems/appium_lib-12.0.1/lib/appium_lib/appium.rb:203:in each'
# /Users/maheshchaudhar/.rvm/gems/ruby-2.7.4/gems/appium_lib-12.0.1/lib/appium_lib/appium.rb:203:in block in promote_appium_methods' # /Users/maheshchaudhar/.rvm/gems/ruby-2.7.4/gems/appium_lib-12.0.1/lib/appium_lib/appium.rb:202:in each'
# /Users/maheshchaudhar/.rvm/gems/ruby-2.7.4/gems/appium_lib-12.0.1/lib/appium_lib/appium.rb:202:in `promote_appium_methods'

thank you. I'll take a look

What is the automationName?

Could you share code when you call promote_appium_methods?

driver = Appium::Driver.new(caps, true)
# Tests expect methods defined on the minispec object
Appium.promote_appium_methods ::Minitest::Spec, driver
in this test code worked, so I'd like to check how you called the method.

@KazuCocoa

Thanks for checking the issue,
here is the code snippet where we call promote_appium_method

self.driver.start_driver
Appium.promote_appium_methods Object

How to create self.driver? I wonder if this is a global driver ($driver) thing.

@KazuCocoa we create driver using, and all things are working fine with appium lib version : 10.6.0
appium_driver = Appium::Driver.new({:caps => self.test_configuration.desired_capabilities, :appium_lib => appium_lib}, true)

I think there is change is "hide_keyboard" method signature, it started working after removing a parameter from hide_keyboard call.

def hide_keyboard(close_key = nil)
self.wrapped_driver.hide_keyboard(close_key)
end

But after that started getting error for :close_app

  method `close_app' not defined in #<Object:0x00007f7ce6aee650>
 # /Users/maheshchaudhar/.rvm/gems/ruby-2.7.4/gems/appium_lib-12.0.1/lib/appium_lib/appium.rb:211:in `remove_method'
 # /Users/maheshchaudhar/.rvm/gems/ruby-2.7.4/gems/appium_lib-12.0.1/lib/appium_lib/appium.rb:211:in `block (3 levels) in promote_appium_methods'
 # /Users/maheshchaudhar/.rvm/gems/ruby-2.7.4/gems/appium_lib-12.0.1/lib/appium_lib/appium.rb:204:in `class_eval'
 # /Users/maheshchaudhar/.rvm/gems/ruby-2.7.4/gems/appium_lib-12.0.1/lib/appium_lib/appium.rb:204:in `block (2 levels) in promote_appium_methods'
 # /Users/maheshchaudhar/.rvm/gems/ruby-2.7.4/gems/appium_lib-12.0.1/lib/appium_lib/appium.rb:203:in `each'
 # /Users/maheshchaudhar/.rvm/gems/ruby-2.7.4/gems/appium_lib-12.0.1/lib/appium_lib/appium.rb:203:in `block in promote_appium_methods'
 # /Users/maheshchaudhar/.rvm/gems/ruby-2.7.4/gems/appium_lib-12.0.1/lib/appium_lib/appium.rb:202:in `each'
 # /Users/maheshchaudhar/.rvm/gems/ruby-2.7.4/gems/appium_lib-12.0.1/lib/appium_lib/appium.rb:202:in `promote_appium_methods'
 # /Users/maheshchaudhar/Documents/coupa_systems_automation/lib/coupa_systems_automation/ui/factories/coupa.rb:75:in `start_driver'

thank you, I'll take a look

mm, I could not reproduce this behavior yet.

remove_method method if method_defined? method

Did you define the same method name in the Object class?

No we dont have this one let me add and check. Thanks

We had methods with same name which was causing this issue. After removing those, things worked