Martin Erlic
Martin Erlic

Reputation: 5667

Ruby + Appium - Locator Strategy 'name' is not supported for this session

C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok': Locator Strategy 'name' is not supported for this session (Selenium::WebDriver::Error::InvalidSelectorError)
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/response.rb:32:in `initialize'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/http/common.rb:83:in `new'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/http/common.rb:83:in `create_response'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/http/default.rb:107:in `request'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/http/common.rb:61:in `call'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/bridge.rb:678:in `raw_execute'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/bridge.rb:656:in `execute'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/bridge.rb:625:in `find_element_by'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/appium_lib-9.4.3/lib/appium_lib/device/device.rb:440:in `find_element'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/appium_lib-9.4.3/lib/appium_lib/driver.rb:739:in `find_element'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/appium_lib-9.4.3/lib/appium_lib/driver.rb:242:in `rescue in block (4 levels) in promote_appium_methods'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/appium_lib-9.4.3/lib/appium_lib/driver.rb:233:in `block (4 levels) in promote_appium_methods'
        from tindermation.rb:46:in `like_button'
        from tindermation.rb:75:in `<main>'
Looking for girls to match...

Apparently name is deprecated in Appium? What is the alternative? Is there some setting in Android Developer Options that will return the xpath, id, class name, accessibility id, etc. for particular UI elements?

Alternatively, I'm using Developer Options to click a UI element at a certain coordinate. For example:

def login_button
  sleep 1
  driver.execute_script 'mobile: tap', :x => 539, :y => 1464, :fingers => 1, :tapCount => 1, :duration => 0.5
  sleep 1
  driver.execute_script 'mobile: tap', :x => 871, :y => 1130, :fingers => 1, :tapCount => 1, :duration => 0.5
  sleep 1
end

But I get this exception:

C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok': Method has not yet been implemented (Selenium::WebDriver::Error::UnknownError)

Why can't I tap the login button?

Upvotes: 0

Views: 1563

Answers (2)

Kaushal Rupani
Kaushal Rupani

Reputation: 186

Currently you need to use either xpath or id.
Alternatively if you have name you can use xpath as
//*[@name='yourName'] .

driver.find_element(xpath: "//*[@name='yourName']").click

Hope it helps!!!

Upvotes: 1

Neetesh Kumar Gupta
Neetesh Kumar Gupta

Reputation: 126

You can use "Appium Inspector", the inbuilt tool with Appium GUI app or the Android SDK tool "uiautomatorviewer" to find the different attributes of UI components of the app.

Upvotes: 1

Related Questions