Skip to content

#574 FIX - #582

Merged
TikhomirovSergey merged 1 commit into
appium:masterfrom
TikhomirovSergey:master
Feb 25, 2017
Merged

#574 FIX#582
TikhomirovSergey merged 1 commit into
appium:masterfrom
TikhomirovSergey:master

Conversation

@TikhomirovSergey

Copy link
Copy Markdown
Contributor

Change list

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)

Details

@vikramvi I could find the rootcause of the bug.
Here: https://github.com/SeleniumHQ/selenium/blob/master/java/client/src/org/openqa/selenium/support/ui/ExpectedConditions.java#L293

the toString() method is invoked. And this method is overriden by RemoteWebElement. So the searching was being invoked... twice :)))

Now this sample test passes:

packageio.appium.java_client.pagefactory_tests;
importio.appium.java_client.android.BaseAndroidTest;
importio.appium.java_client.pagefactory.AndroidFindBy;
importio.appium.java_client.pagefactory.AppiumFieldDecorator;
importio.appium.java_client.pagefactory.WithTimeout;
importorg.junit.Assert;
importorg.junit.Before;
importorg.junit.Test;
importorg.openqa.selenium.WebElement;
importorg.openqa.selenium.support.PageFactory;
importorg.openqa.selenium.support.ui.ExpectedConditions;
importorg.openqa.selenium.support.ui.WebDriverWait;
importjava.util.Calendar;
importjava.util.concurrent.TimeUnit;
importstaticorg.junit.Assert.assertTrue;
publicclassBugReproducingextendsBaseAndroidTest {
privatestaticfinallongACCEPTABLE_DELTA_MILLS = 1500;
@WithTimeout(time = 4, unit = TimeUnit.SECONDS)
@AndroidFindBy(className = "ABC") //this is invalid locator; purposely put upprivateWebElementtextView;
/** * The setting up. */@BeforepublicvoidsetUp() throwsException {
PageFactory.initElements(newAppiumFieldDecorator(driver, 15, TimeUnit.SECONDS), this);
}
publicbooleanisElementPresent(WebElementelementName, inttimeout){
try{
WebDriverWaitwait = newWebDriverWait(driver, timeout);
wait.until(ExpectedConditions.visibilityOf(elementName));
returntrue;
}catch(Exceptione){
returnfalse;
}
}
privatestaticbooleancheckTimeDifference(longexpectedTime, TimeUnitexpectedTimeUnit,
longcurrentMillis) {
longexpectedMillis = TimeUnit.MILLISECONDS.convert(expectedTime, expectedTimeUnit);
try {
Assert.assertEquals(true,
((currentMillis - expectedMillis) < ACCEPTABLE_DELTA_MILLS) && (
(currentMillis - expectedMillis) >= 0));
} catch (Errore) {
Stringmessage = String.valueOf(expectedTime) + " "
+ expectedTimeUnit.toString()
+ " current duration in millis "
+ String.valueOf(currentMillis) + " Failed";
thrownewAssertionError(message, e);
}
returntrue;
}
@TestpublicvoidfindByElementTest() {
longstartMark = Calendar.getInstance().getTimeInMillis();
isElementPresent(textView,2);
/*try { textView.isDisplayed(); } catch (Exception e) { e.printStackTrace(); }*/longendMark = Calendar.getInstance().getTimeInMillis();
assertTrue(checkTimeDifference(4,
TimeUnit.SECONDS, endMark - startMark));
}
}

image

@TikhomirovSergeyTikhomirovSergey added this to the 5.0.0 milestone Feb 24, 2017
@TikhomirovSergeyTikhomirovSergey self-assigned this Feb 24, 2017
@TikhomirovSergey

Copy link
Copy Markdown
ContributorAuthor

@vikramvi@SrinivasanTarget Could you review this PR.

@TikhomirovSergey

Copy link
Copy Markdown
ContributorAuthor

...I should say that the similar bug is contained by common Selenium tools.

@saikrishna321

Copy link
Copy Markdown
Member

Non invited PR review 😉 looks good to me.. Tested and works fine 👍

@SrinivasanTarget

Copy link
Copy Markdown
Member

cool @saikrishna321 👍

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

Awesome 👍

@TikhomirovSergey

Copy link
Copy Markdown
ContributorAuthor

ok. I'm merging.

@TikhomirovSergey
TikhomirovSergey merged commit fe01575 into appium:masterFeb 25, 2017
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.

3 participants

@TikhomirovSergey@saikrishna321@SrinivasanTarget