Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ Selector supports below parameters. Refer to [UiSelector java doc](http://develo
[@QianJin2013]: https://github.com/QianJin2013
[@xiscoxu]: https://github.com/xiscoxu
[@mingyuan-xia]: https://github.com/mingyuan-xia
[@clickdroid]: https://github.com/smitsgit

## Issues & Discussion

Expand Down
10 changes: 10 additions & 0 deletions test/test_device_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ def test_text(self):
self.assertEqual(self.jsonrpc.setText.call_args_list,
[call(self.obj.selector, t) for t in texts])

def test_get_text(self):
self.jsonrpc.clearTextField = MagicMock()
self.jsonrpc.setText.return_value = False

texts = ["abc", "123", "()#*$&"]
for text in texts:
self.jsonrpc.getText.return_value = text
self.assertFalse(self.obj.set_text(text))
self.assertEqual(text, self.obj.get_text())

def test_click(self):
self.jsonrpc.click.return_value = False
corners = ["tl", "topleft", "br", "bottomright"]
Expand Down
2 changes: 1 addition & 1 deletion test/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_start_success(self):
server.ping.return_value = "pong"
server.adb = MagicMock()
server.start()
server.adb.cmd.assert_valled_onec_with('shell', 'uiautomator', 'runtest', 'bundle.jar', 'uiautomator-stub.jar', '-c', 'com.github.uiautomatorstub.Stub')
server.adb.cmd.assert_called_with('shell', 'uiautomator', 'runtest', 'bundle.jar', 'uiautomator-stub.jar', '-c', 'com.github.uiautomatorstub.Stub')

def test_start_error(self):
server = AutomatorServer()
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
envlist = py27, py34, pypy
indexserver =
default = http://pypi.douban.com/simple
default = https://pypi.douban.com/simple

[testenv]
deps =
Expand Down
4 changes: 4 additions & 0 deletions uiautomator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,10 @@ def set_text(self, text):
else:
return self.jsonrpc.setText(self.selector, text)

def get_text(self):
''' get the text from field '''
return self.jsonrpc.getText(self.selector)

def clear_text(self):
'''clear text. alias for set_text(None).'''
self.set_text(None)
Expand Down