Tapping button by it's value or name

226 views
Skip to first unread message

Justin Ison

unread,
Nov 13, 2012, 6:03:58 PM11/13/12
to appium-...@googlegroups.com
Hey guys,

Just digging into appium now. Like what I'm seeing so far! Looked at the appium webdriver example. Is there a way to tap a button based on it's name/value and not index (like below)? I tend not to use the index because most times they are dynamically set and can change when a view changes. 

e.g.
buttons = driver.find_elements_by_tag_name('button')
# buttons[1].click()
buttons.("Submit").click()

Jason Carr

unread,
Nov 14, 2012, 5:57:56 PM11/14/12
to appium-...@googlegroups.com
This is hard to do right now. Hopefully we'll get find_element_by_name implemented soon.

In the mean time, you can iterate on that list and find the element with the 'text' value you want pretty easily, although it will be slow since it queries on each iteration.

Good luck, let us know what you end up with!

Jason
Message has been deleted

James Eisenhauer

unread,
Dec 12, 2012, 5:32:24 PM12/12/12
to appium-...@googlegroups.com
weird...i replied but now it shows as deleted....did i hit the wrong button
Message has been deleted

Jason Carr

unread,
Dec 12, 2012, 5:50:21 PM12/12/12
to appium-...@googlegroups.com
That is very strange. I see two deleted messages in this thread, actually.

James Eisenhauer

unread,
Dec 12, 2012, 5:57:07 PM12/12/12
to appium-...@googlegroups.com
I keep trying to post some code snips and log file stuff and it keep deleting it...basically just showing what I was doing and the success using the iterate method.

Here is the rest of my post and I will put the code snippet here: https://gist.github.com/4272407  

So the main point of my post was a question to ask if anybody has found a creative work around to finding the right element quicker given the current features?

 Also curious if the find by name feature is getting anywhere and if there was somewhere I could help.  I make up for my lack of skill with brute force :-)

Great job so far on the project I really like the cleanness/simpleness of it all.

Thanks!

Jim

Jason Carr

unread,
Dec 12, 2012, 6:13:32 PM12/12/12
to appium-...@googlegroups.com
Thanks Jim!

Brute force is sometimes the first step to finding the best way :).

Jason

Roman Salvador

unread,
Dec 12, 2012, 9:27:56 PM12/12/12
to appium-...@googlegroups.com
Hi, you can also find elements by specifying their name/value in addition of their tagName:

driver.find_element_by_tag_name('button/Submit').click();

On Tuesday, November 13, 2012 3:03:58 PM UTC-8, isonic1 wrote:

James Eisenhauer

unread,
Dec 13, 2012, 1:21:08 PM12/13/12
to appium-...@googlegroups.com
Roman that makes it much better!!  Hooked it all up and is working great.  Much faster :-)

#ruby
 # Challenge Button
    @driver.find_element(:tag_name,"button/Challenges").click
    # Friends Button
    @driver.find_element(:tag_name,"button/Friends").click
    # Messages Button
    @driver.find_element(:tag_name,"button/Messages").click
    # Settings Button
    @driver.find_element(:tag_name,"button/Settings").click
    # My Hub Button 
    @driver.find_element(:tag_name,"button/My Hub").click
    # Sign-Out Button
    @driver.find_element(:tag_name,"button/Sign Out").click

Jim

James Eisenhauer

unread,
Dec 17, 2012, 7:23:23 PM12/17/12
to appium-...@googlegroups.com
Any thoughts on wild carding this?

@driver.find_element(:tag_name,"button/Messages*").click

The button has a notification number on it and of course then changes if you have unread messages.   Thoughts on how to solve?

thanks

jim

Tomek

unread,
Apr 11, 2013, 5:44:01 AM4/11/13
to appium-...@googlegroups.com
Hello,

i have a question, is it works on ios?


i am trying to use in this way in java:
driver.findElement(By.name("textfield/textHere"))

and it shows that i don't have such element, but ia have it in page source also in value and proepr tag name

Jonathan Lipps

unread,
Apr 11, 2013, 11:29:18 AM4/11/13
to Tomek, appium-...@googlegroups.com
You can't use the "xxx/yyy" syntax in Appium anymore (that was for the old python version of appium). But you can use xpath.

driver.findElement(By.xpath("//text[@text='textHere']"))

--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Aniket Gadre

unread,
Apr 11, 2013, 12:57:07 PM4/11/13
to Jonathan Lipps, Tomek, appium-...@googlegroups.com

Regarding xpaths, why do xpaths mentioned in inspector start from index 1 and not 0? Shouldn't they start from 0?

Dan Cuellar

unread,
Apr 12, 2013, 11:22:32 AM4/12/13
to appium-...@googlegroups.com, Jonathan Lipps, Tomek
Reply all
Reply to author
Forward
0 new messages