def receive_text():
     """Receive data from text field"""
     time.sleep(0.2)
     send_keys('^a')
     time.sleep(0.2)
     send_keys('^c')
     send_keys('{RIGHT}')
     received = clipboard.get_data()
     return received
 def test_get_data(self):
     """Make sure that get text from clipboard works"""
     send_keys('abc')
     received = self.receive_text()
     self.assertEqual('abc', received)
Beispiel #3
0
QUICK_OPEN = True
TEST_FILE_PATH = '/tmp/test.txt'

with open(TEST_FILE_PATH, 'w') as test_file:
    test_file.write('This is the beginning of a beautiful friendship!')

app = Application().start("gedit")

app.gedit['Untitled Document 1 - gedit'].wait('ready')

if QUICK_OPEN:
    # This only works if you have the focus
    app.gedit['Untitled Document 1 - gedit'].set_focus()
    # Send Ctrl + O to open the FileChooser directl
    send_keys('^o')
else:
    # Open the file chooser by clicking the button
    app.gedit.Open.click()
    app.gedit['Other Documents...'].click()

# FileChooser opened up
FileChooser = app.gedit.children()[1]
app.gedit['Untitled Document 1 - gedit'].wait('ready')

# Send the ctr+L to switch to editable text
send_keys('^l')
# A better solution would be something like:
# FileChooser.type_keys('^l')
# But this is unimplemented
# Alternatively if you send '/' then it starts by filling in the '/'