PressKeyboardButton
is a function that is accept an argument named self
, since it is causing error on unicode
object, I'm assuming you are passing a unicode string as an argument to your function. String obviously doesn't have any _current_application
attribute defined.
May be you are trying to use a class and mistaking function for a class, try something on these lines -
class KeyboardButton:
def press(self, button):
self._current_application().execute_script("var vKeyboard = target.frontMostApp().keyboard(); vKeyboard.buttons()['" + buttonToPress + "'].tap();");
def _current_application(self):
# add your code.
Or you could just use a function
from AppiumLibrary import AppiumLibrary
def PressKeyboardButton(self, buttonToPress):
current_application().execute_script("var vKeyboard = target.frontMostApp().keyboard(); vKeyboard.buttons()['" + buttonToPress + "'].tap();")
def current_application():
# your code.
Something on these lines, since it is not clear what you are trying to accomplish.