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

Annotation Processors not working in java 10/11 #631

Closed
paulsjohnson91 opened this issue Oct 11, 2018 · 14 comments
Closed

Annotation Processors not working in java 10/11 #631

paulsjohnson91 opened this issue Oct 11, 2018 · 14 comments
Assignees
Milestone

Comments

@paulsjohnson91
Copy link

In java 10 and 11, lazy objects are initializing.

Expected Behavior

@Page
private ExamplePage examplePage;

goTo(examplePage)

@page object should initialize and FluentLenium should go to the page

Current Behavior

examplePage is null so is throwing a NullPointerException.

This also happens with lazy locators with @findby

Context (Environment)

Tried with both Java 10 and 11 on FluentLenium version 3.7.0

@koryl
Copy link
Collaborator

koryl commented Oct 17, 2018

Thank you for your feedback! FluentLenium was checked mainly for jdk8 and I will try to find the reason for such behavior in newer versions. It is important for us to bring FL to the upcoming Java 11.

@koryl koryl added the bug label Oct 17, 2018
@koryl koryl added this to the 3.8 milestone Oct 17, 2018
filipcynarski added a commit that referenced this issue Nov 29, 2018
# Conflicts:
#	examples/cucumber/pom.xml
#	examples/hooks/pom.xml
#	examples/quickstart-chrome/pom.xml
#	examples/quickstart/pom.xml
#	examples/spock/pom.xml
#	examples/spring/pom.xml
#	fluentlenium-assertj/pom.xml
#	fluentlenium-core/pom.xml
#	fluentlenium-cucumber/pom.xml
#	fluentlenium-junit-jupiter/pom.xml
#	fluentlenium-junit-jupiter/src/it/junit-jupiter/pom.xml
#	fluentlenium-junit/pom.xml
#	fluentlenium-junit/src/it/junit/pom.xml
#	fluentlenium-spock/pom.xml
#	fluentlenium-testng/pom.xml
#	fluentlenium-testng/src/it/testng/pom.xml
#	pom.xml
@filipcynarski
Copy link
Member

Looks like it works :) Could you please check w/ 4.0.0 release?

@filipcynarski filipcynarski modified the milestones: 3.8, 4.0.0 Nov 29, 2018
@paulsjohnson91
Copy link
Author

Unfortunately I'm still getting the same issues as before.

java.lang.IllegalArgumentException: Page is mandatory

The annotators are not initialising the page objects.

Checked on version 4.0.0. with Java 11

@slawekradzyminski
Copy link
Member

@paulsjohnson91 Can you please share complete class code?

@paulsjohnson91
Copy link
Author

paulsjohnson91 commented Jan 2, 2019

`
private final String BO_USERNAME = prop("operatorUserName");
private final String BO_PASSWORD = prop("operatorPassword");

@page
private LogInPage logInPage;

@page
private DashboardPage dashboardPage;

@before
public void before(Scenario scenario) {
super.setUpBefore(scenario);
}

@after
public void after(Scenario scenario) {
super.tearDownAfter(scenario);
}

@given("^the operator navigates to back office login page$")
public void the_operator_navigates_to_back_office_login_page() {
goTo(logInPage);
logInPage.isAt();
}
`

@slawekradzyminski
Copy link
Member

@paulsjohnson91 please copy/paste everything with imports. That would be helpful :)

@paulsjohnson91
Copy link
Author

`
package com.backoffice.whgtf.test.bnw.steps.ui.auth;

import static com.backoffice.whgtf.test.bnw.util.PropertyHelper.prop;

import com.backoffice.whgtf.test.bnw.steps.AbstractCucumberTest;
import com.backoffice.whgtf.test.bnw.ui.pom.backoffice.page.DashboardPage;
import com.backoffice.whgtf.test.bnw.ui.pom.backoffice.page.auth.LogInPage;
import cucumber.api.Scenario;
import cucumber.api.java.After;
import cucumber.api.java.Before;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import org.fluentlenium.core.annotation.Page;

public class LogInSteps extends AbstractCucumberTest {

private final String BO_USERNAME = prop("operatorUserName");
private final String BO_PASSWORD = prop("operatorPassword");

@page
private LogInPage logInPage;

@page
private DashboardPage dashboardPage;

@before
public void before(Scenario scenario) {
super.setUpBefore(scenario);
}

@after
public void after(Scenario scenario) {
super.tearDownAfter(scenario);
}

@given("^the operator navigates to back office login page$")
public void the_operator_navigates_to_back_office_login_page() {
goTo(logInPage);
logInPage.isAt();
}

@given("^the operator navigates back to the back office login page$")
public void the_operator_navigated_back_to_the_back_office_login_page() {
goTo(logInPage);
}

@given("^the operator is logged in and on the dashboard$")
public void the_operator_is_logged_in_and_on_the_dashboard() {
goTo(logInPage);
logInPage.isAt();
logInPage.fillAndSubmitForm(BO_USERNAME, BO_PASSWORD);
logInPage.confirmSuccessfulLogIn();
}

@when("^the operator submits login page$")
public void the_operator_submits_login_page() {
logInPage.fillAndSubmitForm(BO_USERNAME, BO_PASSWORD);
}

@then("^the operator is successfully logged in$")
public void the_operator_is_successfully_logged_in() {
logInPage.confirmSuccessfulLogIn();
}

@then("^the operator is successfully logged out$")
public void theOperatorIsSuccessfullyLoggedOut() {
dashboardPage.logout();
logInPage.isAt();
}

@when("^the operator submits invalid login credentials$")
public void theOperatorSubmitsInvalidLoginCredentials() {
goTo(logInPage);
logInPage.isAt();
logInPage.fillAndSubmitForm(BO_USERNAME + "111", BO_PASSWORD);
}

@then("^the operator is not successfully logged in$")
public void theOperatorIsNotSuccessfullyLoggedIn() {
logInPage.confirmUnsuccessfulLogin();
}
}

`

@slawekradzyminski
Copy link
Member

Can you try to extend FluentCucumberTest as stated in docs?
http://fluentlenium.org/docs/test-runners/#cucumber

@paulsjohnson91
Copy link
Author

Hi The AbstractCucumberTest class extends the FluentCucumberTest class.

Thanks,

@koryl
Copy link
Collaborator

koryl commented Jan 4, 2019

Hi @paulsjohnson91, I was trying reproduce mentioned by you issue and I found out that it is not related with Java 11 because it worked for me smoothly.

Please, make sure that your runner class uses
@RunWith(FluentCucumber.class)
instead of
@RunWith(Cucumber.class)
When using Cucumber.class as runner I've noticed the problem and message you have mentioned (but not always which is confusing). When using FluentCucumber.class it worked well.

Let us know if it resolves your issue.

@paulsjohnson91
Copy link
Author

Hi, For the scenario listed above I was not running with a runner I was running directly from the IDE. When we use runners we are using AbstractTestNGCucumberTests not JUnit. This setup was working before with Java8 using both the IDE and the TestNG runner to execute the tests.

@koryl koryl added the cucumber label Jan 4, 2019
@koryl koryl self-assigned this Jan 4, 2019
@koryl
Copy link
Collaborator

koryl commented Jan 4, 2019

Ok, now I understand. There were made few changes to handle integration with Cucumber which are related to you problem. More detail what was changed you can find here #612 and here http://fluentlenium.com/docs/test-runners/#cucumber
I will try to fix this in way to use FluentCucumberTest without any runner and to prevent to adding before and after hooks for all classes (for clarity and better performance).

The quickest way to fix this issue is add this class to your project and extend your AbstractCucumberClass with it:

    import org.fluentlenium.adapter.FluentTestRunnerAdapter;
    import org.fluentlenium.adapter.cucumber.FluentCucumberSharedMutator;

    public class FluentCucumberTest extends FluentTestRunnerAdapter {

        public FluentCucumberTest() {
            super(new FluentCucumberSharedMutator());
        }

        public void before(Scenario scenario) {
            starting(scenario.getName());
        }

        public void after(Scenario scenario) {
            if (scenario.isFailed()) {
                failed(scenario.getName());
            }
            finished(scenario.getName());
        }
    }

This issue will be updated when I found better way for injecting FluentLenium components without necessity for repeating before and after hooks.

koryl added a commit that referenced this issue Jan 4, 2019
@coveralls coveralls mentioned this issue Jan 4, 2019
koryl added a commit that referenced this issue Jan 4, 2019
@koryl
Copy link
Collaborator

koryl commented Jan 4, 2019

I've merged bugfix to develop and it will be incorporated into next version.
@paulsjohnson91, this fix will resolve problem with creating instances of Pages but not with elements annotates with FindBy. If this is still an issue please try earlier mentioned FluentCucumber runner or create elements with use FluentWebElement element = el("#locator") instead.

@paulsjohnson91
Copy link
Author

Great thanks, the page issue was fixed by this as long as I added the following to my test step classes:
@Before public void before(Scenario scenario){ super.before(scenario); }

I'm not currently having issues with elements which are initialised with @findby so everything seems to be working as expected now.

Thanks for the help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants