Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@TikhomirovSergey
Copy link
Contributor

  • interfaces FindsByAndroidUIAutomator, FindsByAccessibilityId and FindsByIosUIAutomation were changed
  • findElement(By) and findElementBy* were overriden. Now they return MobileElement or subclass.

I have tried to override findElements(By) and findElementsBy*. But there are casting problems of java-collections. Also there is a problem of backward compatibility. Sometimes I hate Java :)

@TikhomirovSergey
Copy link
Contributor Author

#162

@Jonahss
Copy link
Member

Jonahss commented Mar 20, 2015

Ha! I knew that I had tried to solve #162 when I first wrote the java-client and then decided it wasn't possible, but #162 convinced me that I was just being dumb in the past.

You don't think it will be confusing to users if indElements(By) and findElementsBy* aren't consistent with the others?

@TikhomirovSergey
Copy link
Contributor Author

Ok. I've just proposed it.

If you consider that this PR is not consistent please close it without merging. Actually I think it is not crucial that users can't get MobileElement without casting.

but #162 convinced me that I was just being dumb in the past.

I am sorry if I made you think so. I was too optimistic. :)

@Jonahss
Copy link
Member

Jonahss commented Mar 20, 2015

Hm. The convenience of not having to cast to MobileElement vs the confusion of having to cast when using plural finders. What does @bootstraponline think?

@bootstraponline
Copy link
Member

I like it. I think the code is cleaner without having to cast all the time.

@TikhomirovSergey
Copy link
Contributor Author

@bootstraponline
...but the necessity to cast an element of the list is still here. Please pay attention.

List<WebElement> I = driver.findElements(by);
MobileElement m = (MobileElement ) l.get(0); 

The architecture of RemoteWebDriver API and Java by itself are both prevent the following use case

List<MobileElement> I = driver.findElements(by);

and

casting

@bootstraponline
Copy link
Member

I think overall, it'll be less casting for the common use case of finding and acting upon an element.

-     MobileElement e = (MobileElement) driver.findElement(MobileBy.AccessibilityId("App"));
+     MobileElement e = driver.findElement(MobileBy.AccessibilityId("App"));

Casting in the list.get(0) case is pretty common in Java.

@bootstraponline
Copy link
Member

It's your PR so if you think it's better not to merge, that's fine. I don't feel strongly either way.

@TikhomirovSergey
Copy link
Contributor Author

Ok @bootstraponline
I think this PR is could be merged because these changes really WORK. But I don't mind if it won't be merged because this solution LOOKS like something one-legged.

So, let @Jonahss make a desicion.

Actually, today or tomorrow I am going to propose the similar changes to C#. And it is possible to provide both usecases:

MobileElement e = driver.findElement(by);
List<MobileElement> l = driver.findElements(by);

@Jonahss
Copy link
Member

Jonahss commented Mar 23, 2015

This is exactly the sort of thing I don't like about Java, but I'm ok with merging this ^.^
Thanks for all the hard work @TikhomirovSergey

Jonahss added a commit that referenced this pull request Mar 23, 2015
@Jonahss Jonahss merged commit 897db67 into appium:master Mar 23, 2015
@TikhomirovSergey
Copy link
Contributor Author

Thank you @Jonahss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants