Now what I really want to do is to put a string on the clipboard. This is possible I read on the internet through:
self.driver.set_clipboard(‘happy testing’)
or
self.driver.set_clipboard_text(‘happy testing’)
What I don’t know is how I actually get access to the driver created through (I assume) the Open Application keyword.
Or is it something else? What do you want to do with the driver? Here is a tutorial of Robot Framework that uses Open Application. Maybe it can help you:
Apologies. I am never very good a phrasing my question.
I have a whole Robot test suite built. Many testcases for iOS, Android and some for dekstop browsers. All built with AppiumLibrary. Now I’d like to make a custom library in python, that exposes methods like driver.set_clipboard().
Use python script to set clipboard
…[Arguments] ${my_text_variable_to_set_to_clipboard}
… Load some python script ${my_text_variable_to_set_to_clipboard}
*** Test Cases ***
Open application and copy to keyboard
Open App Android
Use python script to set clipboard Yay I'm on the clipboard!
Analogous to a facade in architecture, a facade is an object that serves as a front-facing interface masking more complex underlying or structural code.
Here is a tutorial on writing a Facade Design Pattern in Python:
I realize you have said you aren’t experienced as a coder, but I do think that reading up on this and exploring it will help give you that experience. Remember everyone started out a beginner.
Edited to add: Sorry, I did not know what AppiumLibrary is. I looked it up:
This actually is a Facade! Searching for ‘clipboard’ in that repo gives this:
So this AppiumLibrary does use driver.set_clipboard_text(text). My best advice to you is to read through, but if you can’t code this yourself the next best thing is to make a feature request on AppiumLibrary.
Here are some ‘best practices’ on asking for a feature:
And of course, if you feel like you have trouble asking questions, this is a must read:
I had indeed tried to create a class that subclasses AppiumLibrary so that I could use that as a facade to use Appium’s driver.set_clipboard_text(text).
I couldn’t get it to work.
When I call AppiumLibrary’s Open Application keyword, it calls Appium’s open_application() method. This I think creates the ‘driver’ to communicate with the Appium Server I have running locally. I think it is on this driver that the driver.set_clipboard_text(text) method is called.
To be able to do that. I think I need to get that driver instance to my custom Facade. But that’s where I run into a wall. I don’t know how to do that.
I’ll keep trying though :). I’ll create a new Facade class and mess around some more hehe.
The nice thing about a tool like AppiumLibrary is that you can get up and running pretty quickly and write a lot of tests.
The problem, as always, is that eventually you will need something that hasn’t been added yet. I’m a big proponent for learning, and believe you can’t go wrong getting more knowledge. But there is also room for a feature request for AppiumLibrary. Hopefully if you do that this discussion gives you the vocabulary and knowledge to communicate with AppiumLibrary developers in a way that they understand exactly what you need.