0

I have create a python file with the following content

from robot.libraries.BuiltIn import BuiltIn

def scroll_page_to_the_bottom():
    BuiltIn().get_library_instance('AppiumLibrary').execute_script("mobile: scroll", {'direction': 'down'})

When I call from robot file with keyword scroll_page_to_the_bottom I got an error TypeError: too many positional arguments

I thought something wrong with my scripts and I try to use other mobile command such as mobile: deviceInfo and it works perfectly Here is the working execute_script from my code BuiltIn().get_library_instance('AppiumLibrary').execute_script("mobile: deviceInfo")

My question is how to pass command with argument to execute_script?

referring to http://appium.io/docs/en/commands/mobile-command/index.html, I have use the correct format execute_script("mobile: scroll", {'direction': 'down'}) but got an error TypeError: too many positional arguments from robot execution

J. Doem
  • 619
  • 7
  • 21

1 Answers1

0

Your python code is calling the execute_script() method on a AppiumLibrary object, from the robotframework-appiumlibrary package. This method receives only one parameter (script), and you are passing two arguments: 1. the string "mobile: scroll" and 2. the dict {'direction': 'down'}. Hence the TypeError: too many positional arguments exception.

The second example you gave works because you passed the correct number of arguments: the string "mobile: deviceInfo".

The page http://appium.io/docs/en/commands/mobile-command/index.html documents the execute_script() method from the appium-python-client package, and this is a different package. The method you are calling is not there.

dmertins
  • 568
  • 5
  • 11