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

[Feature] Should have a mechanism to not trigger browser when using CubanoTemplateFixture #136

Open
hungdao-testing opened this issue Jul 22, 2021 · 0 comments

Comments

@hungdao-testing
Copy link

My Fixture file is a mix of action needed browser interaction and api services. My idea of writing this file along with markdown file is

  • setUpData: calling createUser service, and use this user across to the spec and NO need to invoke the browser instance <<< in my view, it should relate to Scope.SPECIFICATION. In markdown file, it places on section called Background

  • The methods in the fixture file maps correspondingly to the sections in markdown file (scenarios).

But when calling the fixture file, the background section triggers browser as well, and causes error. So I would like to ask/clarify is there any existing feature to invoke the browser manually ? , or, any ways to handle SPEC_SCOPE without invoking browser instance while using CubanoTemplateFixture ?

package com.rwa.specs.bankaccount.feature;

import com.rwa.pages.HomePage;
import com.rwa.services.BankAccountService;
import com.rwa.workflow.WorkFlow;
import org.concordion.api.*;
import org.concordion.cubano.driver.http.HttpEasyReader;
import org.concordion.cubano.template.framework.CubanoTemplateFixture;

import java.io.IOException;

@FullOGNL
public class OnBoardingFixture extends CubanoTemplateFixture {

    private WorkFlow workFlow;
    private HomePage homePage;

    @ConcordionScoped(Scope.SPECIFICATION)
    private final ScopedObjectHolder<BankAccountService> userDataSpecScope = new ScopedObjectHolder<BankAccountService>() {

        private BankAccountService bankAccountService;

        public void deleteBankAccountService() {
            bankAccountService = null;
        }

        @Override
        public BankAccountService create() {
            bankAccountService = new BankAccountService();
            return bankAccountService;
        }

        @Override
        protected void destroy(BankAccountService bankAccountService) {
            deleteBankAccountService();
        }

    };

    @BeforeExample
    public void setUp() {
        this.workFlow = new WorkFlow(this);
        this.homePage = new HomePage(this);
    }

    public MultiValueResult setUpOnBoardingData(String fullName) throws IOException {
        HttpEasyReader resp = userDataSpecScope.get().createDefaultUserAccountFromFullName(fullName);
        return new MultiValueResult()
                .with("username", resp.getJsonReader().jsonPath("user.username").getAsString())
                .with("password", "s3cret");
    }

    public boolean triggerOnBoardingProcessForUser(String username, String password) throws IOException {
        this.homePage = this.workFlow.loginWorkFlow(username, password);
        this.homePage.getOnBoardingProcessComponent().waitForOnBoardingDialogLoaded();
        return true;
    }

    public MultiValueResult processOnBoardingFlow(String bankName, String routingNumber, String accountNumber) {
        this.getBrowser().getDriver().navigate().refresh();
        return this.homePage
                .getOnBoardingProcessComponent()
                .waitForOnBoardingDialogLoaded()
                .processOnBoardingWithBankingInfo(bankName, routingNumber, accountNumber);
    }


}

=== Markdown file ===

# On-Boarding

As a newly created user, I want the system to walk me through the On-boarding process so that
I could link a bank profile to my user account.


### Rules: OnBoarding process behavior
- The on-boarding process is triggered to the newly created users. 
  It's triggered once user logs into the application, and would be stopped if user finished setting up banking account.

* This rule is dependent on:
  - [Create newly user](SignUp.md#create_new_user)
  
### [Background](-):

Given [Dave Lopp](- "#fullName"), a [newly created user](- "#data=setUpOnBoardingData(#fullName)"), was on the Login page


##### [Scenario:](- "trigger on-boarding process") On-boarding process is triggered for newly created users once they log in

<div>
<p concordion:execute="#result=triggerOnBoardingProcessForUser(#data.username, #data.password)">

When he logs into the application with valid credentials

Then the on-boarding process is triggered [properly](- "c:assert-true=#result")

</p>

</div>


#### [Scenario:](- "on-boarding for users") User could pass the on-boarding process with valid banking information

Given he [was On-boarding process](- "triggerOnBoardingProcessForUser(#data.username, #data.password)")

<div>

<p concordion:execute="#process=processOnBoardingFlow(#bankName,#routingNumber,#accountNumber)">

When he provides valid banking information

|Bank Name|Routing Number|Account Number|
|---|---|---|
|<span concordion:set="#bankName">American Bank</span>|<span concordion:set="#routingNumber">031302997</span>|<span concordion:set="#accountNumber">000123456789</span>|

</p>

</div>

Then he could finish the process [successfully](- "c:assert-true=#process.result")
@hungdao-testing hungdao-testing changed the title [Feature] Should have a mechanism to trigger browser when using CubanoTemplateFixture [Feature] Should have a mechanism to not trigger browser when using CubanoTemplateFixture Jul 22, 2021
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