Skip to content

#764 alternative fix - #769

Merged
TikhomirovSergey merged 6 commits into
appium:masterfrom
TikhomirovSergey:#764_FIX
Nov 21, 2017
Merged

#764 alternative fix#769
TikhomirovSergey merged 6 commits into
appium:masterfrom
TikhomirovSergey:#764_FIX

Conversation

@TikhomirovSergey

Copy link
Copy Markdown
Contributor

Change list

#764 FIX. This change was made according to the confersation #765

Types of changes

  • No changes in production code.
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

The asking for the current platform was optimized.
The asking for the browser or not was optimized.
Also:
- WidgetListInterceptor was optimized
- some code style improvements
@TikhomirovSergey

Copy link
Copy Markdown
ContributorAuthor

@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()))

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
ContributorAuthor

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


private static By getBy(By currentBy, SearchContext currentContent) {
if (!ContentMappedBy.class.isAssignableFrom(currentBy.getClass())) {
return currentBy;

Copy link
Copy Markdown
Contributor

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

List<WebElement> list = searchContext.findElements(by);
List<WebElement> list = searchContext
.findElements(getBy(by, searchContext));
if (list.size() > 0) {

Copy link
Copy Markdown
Contributor

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())) {

Copy link
Copy Markdown
Contributor

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));

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
ContributorAuthor

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. */publicByuseContent(@NonnullContentTypetype) {
checkNotNull(type);
currentContent = type;
returnthis;
}

@mykola-mokhnachmykola-mokhnach left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just minor comments

@TikhomirovSergey

Copy link
Copy Markdown
ContributorAuthor

@mykola-mokhnach I have improved some things that you pointed.
@SrinivasanTarget I am waining for your review.

@appiumappium deleted a comment Nov 19, 2017

@SrinivasanTargetSrinivasanTarget left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@SrinivasanTarget

Copy link
Copy Markdown
Member

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 -> {

Copy link
Copy Markdown
Contributor

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.originalDriverone.

@TikhomirovSergey

Copy link
Copy Markdown
ContributorAuthor

@vrunoa
Also it is interesting to know about the time. Was it increased or reduced with this change on your environment? I will wait for a day or two days.

@appiumappium deleted a comment Nov 19, 2017
@vrunoa

Copy link
Copy Markdown

@TikhomirovSergey i'm running tests, i'll get back to you as soon as I have some results.

@TikhomirovSergey

Copy link
Copy Markdown
ContributorAuthor

@vrunoa and what the result?

@TikhomirovSergey

Copy link
Copy Markdown
ContributorAuthor

ping @vrunoa

@vrunoa

Copy link
Copy Markdown

@TikhomirovSergey sorry for the delay. I'm session a lot less getSession calls and test times got reduced. Lets merge it.

@TikhomirovSergey

TikhomirovSergey commented Nov 21, 2017

Copy link
Copy Markdown
ContributorAuthor

@vrunoa How much time was reduced? I will merge it later today

@vrunoa

Copy link
Copy Markdown

@TikhomirovSergey from 2hs to 50minutes approximately.

@SrinivasanTarget

Copy link
Copy Markdown
Member

2hs to 50minutes approximately

Awesome

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@TikhomirovSergey@SrinivasanTarget@vrunoa@mykola-mokhnach