Skip to content
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

@Retrу on @FindBy broken since #62 #74

Closed
acmi opened this issue Apr 4, 2019 · 0 comments
Closed

@Retrу on @FindBy broken since #62 #74

acmi opened this issue Apr 4, 2019 · 0 comments

Comments

@acmi
Copy link
Contributor

acmi commented Apr 4, 2019

Test to reproduce

import io.qameta.atlas.core.Atlas;
import io.qameta.atlas.core.api.Retry;
import io.qameta.atlas.webdriver.extension.FindBy;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.NotFoundException;
import org.openqa.selenium.WebElement;

import static io.qameta.atlas.webdriver.testdata.ObjectFactory.mockWebDriver;
import static io.qameta.atlas.webdriver.testdata.ObjectFactory.mockWebElement;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.when;

public class FindByRetrierTest {

    @Test
    public void retryChildFind() {
        WebElement parentOrigin = mockWebElement();
        WebElement childOrigin = mockWebElement();

        when(parentOrigin.findElement(By.xpath("//div"))).then(new Answer<WebElement>() {
            Long startWaitingTime;

            @Override
            public WebElement answer(InvocationOnMock invocation) {
                if (startWaitingTime == null) {
                    startWaitingTime = System.nanoTime();
                }
                if (System.nanoTime() - startWaitingTime < MILLISECONDS.toNanos(6000)) {
                    throw new NotFoundException();
                }
                return childOrigin;
            }
        });
        when(childOrigin.isDisplayed()).thenReturn(true);

        Atlas atlas = new Atlas(new WebDriverConfiguration(mockWebDriver()));
        ParentElement parent = atlas.create(parentOrigin, ParentElement.class);

        assertThat(parent.child().isDisplayed(), is(true));
    }

    interface ParentElement extends AtlasWebElement {
        @Retry(timeout = 8000)
        @FindBy("//div")
        AtlasWebElement child();
    }

}
admizh pushed a commit to admizh/atlas that referenced this issue Jul 4, 2019
now RetryerContext is mandatory and should be injected to atlas config
Re-designed Retryer's, now we use global RetryerContext as default
ISExtension (for momentary checking)
now beforeMethod return configuration instance for alteration

fixes:
qameta#81
qameta#79
qameta#74
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

No branches or pull requests

1 participant