Instruments fails to execute send_keys intermittently. How should that be handled?

573 views
Skip to first unread message

Jessica Sachs

unread,
Jul 11, 2014, 11:31:28 AM7/11/14
to appium-...@googlegroups.com
Hey, I posted this question on StackOverflow in the Appium tag 

But here's the info repeated:

The Problem: I'm using Appium's python client to `send_keys` to a `WebElement`.

And Instruments decides it shouldn't tap certain keys sometimes.
This is a pain when I'm trying to do things like login. I need to be able to reliably type or programmatically set values on input fields.

This is (more or less) what I'm doing, and here's the gist of Instruments complaining about it

    el = driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]/UIATextField[1]')
    el.click()
    el.send_keys('BECKERMA')

All pretty standard. And it usually works

But usually isn't cutting it. I need something solid.

Possible Solutions?

I think I can make `send_keys` work if I do some sort of try/retry if I get a `WebDriverException` back.
But what would be really cool is if I could set the value of the element through a JavaScript `execute_script` - or better yet - a selenium python binding!
I don't know JavaScript, and I've already tried searching for how to set the value on the object without doing `sendKeys` but I've come up blank.
Any ideas would be really helpful. Thanks!

bootstrap online

unread,
Jul 11, 2014, 11:40:03 AM7/11/14
to Jessica Sachs, appium-...@googlegroups.com
1. don't use xpath
2. use setValue on iOS, avoid send_keys
https://github.com/appium/ruby_lib/blob/e2c82cc95d1443a31f73871fce96ae8aa4e99b6f/lib/appium_lib/ios/patch.rb#L36
> --
> http://appium.io
> ---
> You received this message because you are subscribed to the Google Groups
> "Appium-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to appium-discus...@googlegroups.com.
> Visit this group at http://groups.google.com/group/appium-discuss.
> For more options, visit https://groups.google.com/d/optout.

Jessica Sachs

unread,
Jul 11, 2014, 12:35:30 PM7/11/14
to appium-...@googlegroups.com, je...@sheeptest.com
1. Thank you, but i'm stuck with it (not my decision). Is there a post or something I can read that talks about why xpaths are evil, and I can pass that on?

2. what is setValue? do I literally just say:
driver.setValue('BECKERMA')

in python? 

bootstrap online

unread,
Jul 11, 2014, 12:49:39 PM7/11/14
to Jessica Sachs, appium-...@googlegroups.com
On Fri, Jul 11, 2014 at 12:35 PM, Jessica Sachs <je...@sheeptest.com> wrote:
> 1. Thank you, but i'm stuck with it (not my decision). Is there a post or
> something I can read that talks about why xpaths are evil, and I can pass
> that on?

XPath may return random elements due to the way it's implemented for
native apps. Maybe this isn't a concern for your use case. Issue
tracker has details.

> 2. what is setValue? do I literally just say:
>
>> driver.setValue('BECKERMA')

No, it's UIAutomation JavaScript used with execute script.

Jessica Sachs

unread,
Jul 11, 2014, 1:08:14 PM7/11/14
to appium-...@googlegroups.com, je...@sheeptest.com
1. That should be a good enough reason.
2. Sorry yeah, I just saw your ruby_lib example. Thank you!

Will post back with results.

Jessica Sachs

unread,
Jul 11, 2014, 1:19:36 PM7/11/14
to appium-...@googlegroups.com, je...@sheeptest.com
Works perfectly. Thank you!


On Friday, July 11, 2014 12:49:39 PM UTC-4, bootstraponline wrote:

Patrick Shay

unread,
Jul 11, 2014, 9:11:06 PM7/11/14
to appium-...@googlegroups.com, je...@sheeptest.com
I am having a similar issue to you but I still don't understand the fix.  (I'm new to automation)
How did you get the JavascriptExecutor to find the UIATextField element?

bootstrap online

unread,
Jul 11, 2014, 9:36:55 PM7/11/14
to Patrick Shay, appium-...@googlegroups.com, Jessica Sachs
First find the textfield normally then use the element ref to call set value.
Reply all
Reply to author
Forward
0 new messages