How to use find_element with resource ids in Ruby

I’m looking for an example of how to find an element by resource id using Ruby. The examples I’ve found in Java use selenium-webdriver’s By method, but I cannot find sufficient documentation on how to use By in Ruby. Does anyone have a pointer to such an example?

Thanks for the response, Bootstrap. I got it working. I used find_element(:id, resource_id)

When I tried to use id(resource_id), it produce an error. I’m using head of line appium, 8fdcf83

id is just an alias for find_element :id. What error did it generate?

Thank you for the pointer, @bootstrap! Once you locate an element, what sort of actions can you do on them? I will try it out. Are all the methods available for capybara available for appium_capybara? It would be great if you add some more specs for QA folks. Thanks, for the quick response!


Reading the source code is the best way to understand what you can do. I don’t use appium anymore. If you send pull requests I’m sure the other devs will appreciate it.

Yeah, okay! I will give it a try, but my ruby is not that great. I just know basic ruby scripting and google the syntax I need.
BTW, I was able to do this for android:

element :login_button, :id, 'welcome_login_button'

def click_login_button

And in my spec:

require_relative '../../spec_helper_test'
require './pages/landing_page'

describe 'Android Test' do
  before(:each) do
    @landing_page =

  it 'should be able to go to login page' do

You can use xpath method, like this:

element = xpath("//android.widget.TextView[contains(@resource-id,‘text_view_bla’)]")


element = xpath("//android.widget.TextView[starts-with(@resource-id,’'package:id/text_view_bla)]")


element = find_elements(:xpath, “//android.widget.TextView[starts-with(@resource-id,’'package:id/text_view_bla)]”)