1

I have a pretty extensive Robot Framework suite that I've built with AppiumLibrary. For the sake of the question I've created a very basic example of what it looks like. What I want to do is use python to call a method (from Appium, not AppiumLibrary) on the instance of the driver/app that I've opened using AppiumLibrary's keyword: Open Application.

To be able to call driver.set_clipboard_value() on this driver I need to create a custom library. To test if I can even get access to the driver or application or whatever it is that I need, I've created the scripts below.

The result I get is:

==============================================================================
App-Bevestigen                                                                
==============================================================================
Clipboard                                                             | FAIL |
No library 'AppiumLibrary' found.
------------------------------------------------------------------------------
App-Bevestigen                                                        | FAIL |
1 test, 0 passed, 1 failed
==============================================================================

How can I get access to the current instance of the library? As I understand it, if I get that, I can get access to the current_application. And once I have that, I can call things like 'driver.set_clipboard_value()'.

Although I do feel like if I have access to the current application, I would also still need op expose this 'driver.set_clipboard_value()' method. I'm a bit foggy on it all. I've spent 2 days trying to figure this out with no luck.

I greatly appreciate any help that can be given!

Thanks :)

I did find this article: Robot framework: how can I get current instance of selenium webdriver to write my own keywords? Which is where I use the Python script from. But it doesn't work for me.

My oversimplified Robot script with AppiumLibrary keywords:

*** Settings ***
Library     AppiumLibrary
Library     SetClipboardValue.py
*** Test Cases ***

Open application and copy to clipboard
    Open Application
        ...    http://localhost:${APPIUM-PORT-ANDROID}
        ...    appActivity=${appActivity}
        ...    appPackage=${appPackage}
        ...    automationName=${AUTOMATION-NAME-ANDROID}
        ...    noReset=${NO-RESET-TestApp}
        ...    platformName=${PLATFORM-NAME-ANDROID}
        ...    udid=${UDID-ANDROID}
        ...    alias=TestApp


    ${current_app_info}=    get current application
    Log To Console    ${current_app_info}

My script to attempt to get information on the current open application:

from robot.libraries.BuiltIn import BuiltIn

def get_current_application():
    return BuiltIn().get_library_instance('AppiumLibrary')._current_application()

0 Answers0