appium / ruby_lib

:gem: Ruby library for Appium
http://rubygems.org/gems/appium_lib
216 stars 160 forks source link

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

Closed maheshchaudharCoupa closed 2 years ago

maheshchaudharCoupa commented 2 years ago

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 #

/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' 
KazuCocoa commented 2 years ago

thank you. I'll take a look

KazuCocoa commented 2 years ago

What is the automationName?

Could you share code when you call promote_appium_methods?

https://github.com/appium/ruby_lib/blob/8448f299ad91cf47f69c961da811310cd13d906b/android_tests/lib/run.rb#L28-L30 in this test code worked, so I'd like to check how you called the method.

maheshchaudharCoupa commented 2 years ago

@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

KazuCocoa commented 2 years ago

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

maheshchaudharCoupa commented 2 years ago

@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)

maheshchaudharCoupa commented 2 years ago

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'
KazuCocoa commented 2 years ago

thank you, I'll take a look

KazuCocoa commented 2 years ago

mm, I could not reproduce this behavior yet.

KazuCocoa commented 2 years ago

https://github.com/appium/ruby_lib/blob/a5d4c4f08cd3fc5d2ca575595f0741b4d22bf7b9/lib/appium_lib/appium.rb#L211

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

maheshchaudharCoupa commented 2 years ago

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

maheshchaudharCoupa commented 2 years ago

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