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"
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.
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.
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:
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?
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’)]")