Appium 1.5 fails to find_element_by_name

Real device ipad 8.4
Language: Python
Ran the test on Appium 1.4.16 and then repeated the test after upgrade to Appium 1.5
find_element_by_name was working on 1.4.16 but shows following error on 1.5.
I dont want to use find_element_by_xpath.
Anyone else having the same issue? what solution have you found? TIA

File “features/steps/support/views.py”, line 19, in
self.sign_up_button = lambda: self.driver.find_element_by_name(“Sign Up with Email”) if self.is_IOS
File “/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py”, line 302, in find_element_by_name
return self.find_element(by=By.NAME, value=name)
File “/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py”, line 662, in find_element
{‘using’: by, ‘value’: value})[‘value’]
File “/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py”, line 173, in execute
self.error_handler.check_response(response)
File “build/bdist.macosx-10.10-intel/egg/appium/webdriver/errorhandler.py”, line 29, in check_response
raise wde
InvalidSelectorException: Message: u"Locator Strategy ‘name’ is not supported for this session"

1 Like

Name locator strategy is removed on 1.5

Remove long-deprecated name locator strategy

thanks. updating my test code to use xpath.

but everyone knows xpath is bad in the long run.

I don’t know what to do at this time. But I will talk to my developers and see what we can figure out.

@alangithubtrader @MS using id is the best approach. http://sauceio.com/index.php/2015/09/advanced-locator-strategies/

This way you are making sure that your app is accessible as well.

As usual developers are always busy , so create branch add ids and submit PR ( just like I’m doing :slight_smile: )

Regards,
Vikram

2 Likes

@alangithubtrader @VikramVI thats the concern, xpath is bad. and my app dont have id \ label. Thanks for the feedbacks.

What pray tell have you got to replace finding elements by name?
Most android screens have the same id and class for every menu element.
The only thing that differentiates the elements is the “text” attribute.

Fortunately I have all my clicks going through an intermediate method, done that way originally to perform screen shots with every click. I’ve replaced the lookup by name with driver.findElementByXPath( String.format( “//*[@text=”%s"]", name ));

Removing find_element_by_name creates extra trouble for us too. What’s the replacement if by_name is deprecated? Don’t think xpath is a good choice, as it’s the attribute that tends to change most on the UI. If we want to stay with find by name/text/content-description, seems we have to use android’s UIAutomator, which is platform-dependent. This is a retrogress for Appium from test writer’s point of view.

1 Like

I haven’t installed 1.5 yet but have been doing ALL of my Appium development using xpath exclusively and successfully. But I’m forced to do this as my AUT doesn’t currently have accessibility IDs at this time. So visible text is my only unique identifier I can rely on. Thus xpath to the rescue.

locators["settings.security_notifications_slider_label"] = '//UIAStaticText[@name="Security Notifications"]'

The reason people jump to saying “xpath is bad, never use xpath” is when they’re composing horribly brittle xpath based on meaningless nested indexes like:

'//UIATableGroup[2]/UIATableCell[7]/UIAStaticText[4]'

Better yet xpath allows you to find elements based on specific relationships in the page source using xpath axes.

locators["cases_and_contracts.special_all_open_cases"] = \
'//UIATableGroup[@name="SPECIAL"]/following-sibling::UIATableCell[@name="All Open Cases"]'
4 Likes

hi guys,
By.linkText is not available either

org.openqa.selenium.InvalidSelectorException: Locator Strategy ‘link text’ is not supported for this session (WARNING: The server did not provide any stacktrace information)

It seems id, xpath, and className only available for appium 1.5 (iOS), am I right?

Hi,

For me (in ruby),
find_element(:name, "Button_Name")
becomes
find_element(:accessibility_id, "Button_Name")

1 Like

Hi,

Had the same problem in python,the solution i found:
instead- wd.find_element_by_name(‘OK’)
you can use - wd.find_element_by_xpath("//*[contains(@text, ‘OK’)]")

1 Like

find_element_by_accessbilityId() from 1.5 appium onwards which you used find with name.