-
-
Notifications
You must be signed in to change notification settings - Fork 759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: avoid casting to RemoteWebElement #1345
refactor: avoid casting to RemoteWebElement #1345
Conversation
* instead, cast to interface HasIdentity (because it's a weaker type). * this commit is similar to https://github.com/appium/java-client/pull/432/files Some background: as a developer of framework which uses proxies for WebElement (Selenide), I cannot create proxy for RemoteWebElement since it's an abstract class, not interface.
@@ -85,8 +85,8 @@ public ElementOption withElement(WebElement element) { | |||
checkNotNull(element); | |||
checkArgument(true, "Element should be an instance of the class which " | |||
+ "extends org.openqa.selenium.remote.RemoteWebElement", | |||
(RemoteWebElement.class.isAssignableFrom(element.getClass()))); | |||
elementId = RemoteWebElement.class.cast(element).getId(); | |||
(HasIdentity.class.isAssignableFrom(element.getClass()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not to use instanceof?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. I just tried to make a minimal change. You never know what can go wrong. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing is ideal. Lets do it properly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
(RemoteWebElement.class.isAssignableFrom(element.getClass()))); | ||
elementId = RemoteWebElement.class.cast(element).getId(); | ||
(HasIdentity.class.isAssignableFrom(element.getClass()))); | ||
elementId = HasIdentity.class.cast(element).getId(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can explicit typecast be used here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -85,8 +85,8 @@ public ElementOption withElement(WebElement element) { | |||
checkNotNull(element); | |||
checkArgument(true, "Element should be an instance of the class which " | |||
+ "extends org.openqa.selenium.remote.RemoteWebElement", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this message should be updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Some background: as a developer of framework which uses proxies for WebElement (Selenide), I cannot create proxy for RemoteWebElement since it's an abstract class, not interface.
Change list
Please provide briefly described change list which are you going to propose.
Types of changes
What types of changes are you proposing/introducing to Java client?
Put an
x
in the boxes that applyDetails
Please provide more details about changes if it is necessary. If there are new features you can provide code samples which show the way they
work and possible use cases. Also you can create gists with pasted java code samples or put them here using markdown.
About markdown please read Mastering markdown and Writing on GitHub