-
-
Notifications
You must be signed in to change notification settings - Fork 764
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
#764 alternative fix #769
#764 alternative fix #769
Conversation
Also: - WidgetListInterceptor was optimized - some code style improvements
@vrunoa You can review it too. It would be cool if you could try to test this change on your environment. |
ElementMap element = Optional.ofNullable(mobileElementMap.get(String | ||
.valueOf(hasSessionDetails.getAutomationName()).toLowerCase().trim())) | ||
ElementMap element = Optional.ofNullable(mobileElementMap.get( | ||
String.valueOf(platform).toLowerCase().trim())) |
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.
does it make any sense to use String.valueOf
for values of type String?
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.
@mykola-mokhnach It may return null
value
@@ -67,6 +69,15 @@ public AppiumElementLocator(SearchContext searchContext, By by, boolean shouldCa | |||
this.exceptionMessageIfElementNotFound = "Can't locate an element by this strategy: " + by.toString(); | |||
} | |||
|
|||
private static By getBy(By currentBy, SearchContext currentContent) { | |||
if (!ContentMappedBy.class.isAssignableFrom(currentBy.getClass())) { | |||
return currentBy; |
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.
it might be easier to understand the code if this condition had an explanation comment
@@ -114,7 +125,8 @@ public WebElement findElement() { | |||
List<WebElement> result; | |||
try { | |||
result = waitFor(() -> { | |||
List<WebElement> list = searchContext.findElements(by); | |||
List<WebElement> list = searchContext | |||
.findElements(getBy(by, searchContext)); | |||
if (list.size() > 0) { |
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.
return list.size() > 0 ? list : null
|| !HasSessionDetails.class.isAssignableFrom(originalDriver.getClass())) { | ||
hasSessionDetails = null; | ||
HasSessionDetails hasSessionDetails = ofNullable(this.originalDriver).map(webDriver -> { | ||
if (!HasSessionDetails.class.isAssignableFrom(originalDriver.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.
originalDriver
-> webDriver
@Override public WebElement findElement(SearchContext context) { | ||
return context.findElement(map.get(getCurrentContentType(context))); | ||
return context.findElement(map.get(currentContent)); |
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.
is it ok if map.get
returns null in any of these methods?
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.
It is not possible. It will use NATIVE_MOBILE_SPECIFIC as it is defined by default or it will use HTML_OR_DEFAULT when there is no SearchContext
which also implements ContextArare
or HasSessionDetails
. Also it will use HTML_OR_DEFAULT when HasSessionDetails.isBrowser
returns true
or current context != NATIVE_CONTEXT
.
Also there is the method
/**
* This method sets required content type for the further searching.
* @param type required content type {@link ContentType}
* @return self-reference.
*/
public By useContent(@Nonnull ContentType type) {
checkNotNull(type);
currentContent = type;
return this;
}
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.
LGTM, just minor comments
@mykola-mokhnach I have improved some things that you pointed. |
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.
👍
LGTM |
HasSessionDetails hasSessionDetails = ofNullable(this.originalDriver).map(webDriver -> { | ||
if (!HasSessionDetails.class.isAssignableFrom(originalDriver.getClass())) { | ||
this.webDriver = unpackWebDriverFromSearchContext(context); | ||
HasSessionDetails hasSessionDetails = ofNullable(this.webDriver).map(webDriver -> { |
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 meant it's better to use the mapped local variable webDriver ->
inside the lambda handler rather than class-level this.originalDriver
one.
@vrunoa |
@TikhomirovSergey i'm running tests, i'll get back to you as soon as I have some results. |
@vrunoa and what the result? |
ping @vrunoa |
@TikhomirovSergey sorry for the delay. I'm session a lot less getSession calls and test times got reduced. Lets merge it. |
@vrunoa How much time was reduced? I will merge it later today |
@TikhomirovSergey from 2hs to 50minutes approximately. |
Awesome |
Change list
#764 FIX. This change was made according to the confersation #765
Types of changes