removed name locator strategy from android and ios drivers along with tests by SrinivasanTarget · Pull Request #313 · appium/java-client
Hi @SrinivasanTarget
First of all let's add descriptions of PR. Ok?
I'm against these changes as they are because:
- it is breaking and harmful for users. Also we should keep backward compatibility with server 1.4x for sometime.
- I'm not sure that tests will pass;
Take a look at these
https://github.com/appium/java-client/pull/313/files#diff-54b126e009942041858b50db621bc3aeR121
https://github.com/appium/java-client/pull/313/files#diff-54b126e009942041858b50db621bc3aeR127 - Also I'm not sure that By.name is deprecated for Selendroid. Also I couldn't check it because of some current problems with 1.5.x. @bootstraponline @imurchie Is By.name not supported by Selendroid mode? It can be used instead of accessibility.
@SrinivasanTarget
But you can make some improvements and help me to resolve #311
What should be done if you want this PR get merged:
- revert changes which require reversion. Read my comments.
- The name option of annotations should be annotated Deprecated. You can do it this way
@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.TYPE}) public @interface AndroidFindBy { String uiAutomator() default ""; String accessibility() default ""; String id() default ""; @Deprecated /** * By.name selector is not supported by Appium server node since 1.5.x. * So this option is going to be removed further. Be careful. */ String name() default ""; String className() default ""; String tagName() default ""; String xpath() default ""; }
So users will be warned and they will have time to improve their projects before migration to 1.5.x. We will remove it later. But I still don't know which name options should be deprecated. @bootstraponline @imurchie is By.name deprecated for Selendroid? One more question. Why By.name is deprecated for iOS? iOS-elements have the name tag, I think.
So the point
mark name parameter Decrecated as By.name selector is not supported by native app automation
will be finished.
- You could finish this point
org.openqa.selenium.InvalidSelectorException should be handled.
The target code is here:
| static boolean isInvalidSelectorRootCause(Throwable e) { |
org.openqa.selenium.InvalidSelectorException: Locator Strategy 'css selector' is not supported for this session (WARNING: The server did not provide any stacktrace information)
is thrown and it is not being handled here. We should keep it backward compatible with Appium node 1.4x for some time. So you could improve this method the following way:
1 firstly it checks the excepion type. If it is org.openqa.selenium.InvalidSelectorException then method should return true.
2 if 1) has a negative result then it checks exception message. It could use regexps. If message is convenient to the previous pattern
| private final static String INVALID_SELECTOR_PATTERN = "Invalid locator strategy:"; |
or
Locator Strategy 'xxxr' is not supported bla-bla-bla
then then method should return true.
3 if both 1) and 2) have negative results then these steps are repeated recursively with the cause of exception.