serenity-bdd / serenity-cucumber

Cucumber integration for the Serenity BDD Reporting library
Other
78 stars 74 forks source link

How to launch unique browser instance for each feature when they are associated with indidual Epic folders? #262

Closed r2d2-github closed 3 years ago

r2d2-github commented 3 years ago

Hi @wakaleo,

I have my project structure where there are more than 20 EPICS associated with different Feature files. Each feature has again many scenarios to perform a test.

**Resources**
**_->features
-->001_Login_and_logout
---->login_journey_1
---->login_journey_2
---->login_journey_3

-->002_Password
---->password_journey_1
---->password_journey_2
---->password_journey_3

-->003_Payments
---->payments_journey_1
---->payments_journey_2
---->payments_journey_3_**

and so on...

Please check the glimpse of a structure in the below image.

image

Currently following are the properties I have added to the serenity.properties

serenity.take.screenshots=AFTER_EACH_STEP serenity.requirement.types=epic serenity.restart.browser.for.each=scenario serenity.use.unique.browser=true restart.browser.for.each=never serenity.browser.maximized=true

And my runner file is: @RunWith(CucumberWithSerenity.class) @CucumberOptions( glue = {"com.java.test.stepdefinitions"}, plugin = {"pretty"}, features = "src/test/resources/features" ) public class FullTestSuite { }

my serenity.conf is something like below: environments { qa { webdriver.app1.url = "https://www.mycompanyqaapplication1.com/" webdriver.app2.url = "https://www.mycompanyqaapplication2.com" webdriver.app3.url = "https://www.mycompanyqaapplication3.com" } pprod { webdriver.app1.url = "https://www.mycompanypprodapplication1.com/" webdriver.app2.url = "https://www.mycompanypprodapplication2.com" webdriver.app3.url = "https://www.mycompanypprodapplication3.com" } uat { webdriver.app1.url = "https://www.mycompanyuatapplication1.com/" webdriver.app2.url = "https://www.mycompanyuatapplication2.com" webdriver.app3.url = "https://www.mycompanyuatapplication3.com" } }

Following are my serenity versions from pom.xml:

UTF-8 2.3.33 2.3.33 2.3.33 1.0.3 3.0.0-M3 3.0.0-M3 3.0.0-M2 3.8.0 My requirement is to run all these tests from all epic->features in sequential order using only ONE browser at an instance, or at least one browser at a time for each feature after feature run. I am able to run any single feature when its specific file path is declared in a runner file, but when I attempt to run more than one feature, multiple browsers are initiated. Could you please assist me with how to run only one browser session for the whole execution using the serenity property?
wakaleo commented 3 years ago

Have you tried serenity.restart.browser.for.each=feature? It's generally not a good idea to rely on the order of your scenarios, though - each scenario should ideally be independent and illustrate a different rule or example.

r2d2-github commented 3 years ago

Hi @wakaleo, yes I have tried this also

serenity.restart.browser.for.each=feature

And no luck

r2d2-github commented 3 years ago

Hi @wakaleo, could you please suggest some solution for this issue? Currently, multiple browsers (more than 40-50 instances) are hampering the test suite and as I mentioned application will not allow a single user to log in at multiple browser instances at the same time. They should run in the order they exist in a single browser at all the time.

wakaleo commented 3 years ago

You want a single browser shared across ALL of the features?

r2d2-github commented 3 years ago

Hi @wakaleo, yes you are right. eg: if you refer to the structure I have, the login_journey_1 should run in a single browser first, and once it completes, the second feature login_journey_2 should initiate a new browser and when this is completed, the third feature login_journey_3 should be initiated. At any time only one browser instance should be initiated for each feature scenarios.

Resources ->features -->001_Login_and_logout ---->login_journey_1 ---->login_journey_2 ---->login_journey_3

-->002_Password ---->password_journey_1 ---->password_journey_2 ---->password_journey_3

-->003_Payments ---->payments_journey_1 ---->payments_journey_2 ---->payments_journey_3

wakaleo commented 3 years ago

serenity.restart.browser.for.each=feature should do that, but it doesn't seem to work in the current version, so probably a bug.

r2d2-github commented 3 years ago

Please let me know if you need further details from my side to resolve it.

wakaleo commented 3 years ago

Put a breakpoint in the close() method of WebDriverFacade and see if you can figure out why it is restarting for each scenario - that behaviour should be prevented by the property mentioned above.

r2d2-github commented 3 years ago

Hi @wakaleo, I have tried to debug my actual work project, but could not successful using multiple browsers due to restricted access for each user I have. However, I have created the same clone repository to reproduce this issue (using the e-commerce website as an example) in the below project. Could you please have a look at it:

git clone git@github.com:ibrahimkhaleel/serenity-cucumber-defect-reproduce-epics-level.git

Following are some issues and observations I would like to mention here:

  1. When features are created per Epic level folders, all features are initiated in execution instead of one by one.
  2. Some features are shown as NOT RUN status even when they are executed during test ex: UK and USA feature files
  3. _serenity. Take. Screenshots=FOR_EACHACTION is not capturing all screenshots as expected. Looks like it captures the same as BEFORE_AND_AFTER_EACH_STEP and AFTER_EACH_STEP

Please let me know the shared project is accessible for you. Thank you.

wakaleo commented 3 years ago

Thanks, I will take a look when I have a chance.

r2d2-github commented 3 years ago

Good Morning @wakaleo, Could you please check this issue?

I have given a try executing my tests in a standard manner after removing all my Epic folders and moved all my . features files to resources=>features and I still observe all features are started running on multiple browsers, instead of one by one. My properties are set to serenity. restart. browser. for. each=feature

Could you please confirm if Serenity allows running feature by feature whether .features are in the Features folder or are they in Epics under Features? This issue has created a major blocker for my project to continue with Serenity. Please assist to resolve it.

wakaleo commented 3 years ago

It should work but it seems to be a defect. I will look at it when I get a chance. If it is a major blocker for your project, the best option would be to get some commercial support for your company (https://johnfergusonsmart.com/serenity-bdd-mentoring/).

r2d2-github commented 3 years ago

Hi @wakaleo, All our Dev and QA should be free and open-source tools. I am afraid the company will not approve funding for any commercial support for this. I will wait when you to fix this issue. In the meantime could you please advise which lower version of serenity I can use where this issue does not exist? Thank you so much for your time on this issue in advance.

Currently, it is 2.3.33

image

wakaleo commented 3 years ago

Hey @ibrahimkhaleel open-source projects are "free as in freedom" - you are free to use them, review their code, contribute, and enhance them (that's why it is called "open source").

However, supporting such projects takes time, effort and knowledge. None of which come free to the contributors. After all, we have to take time away from other activities to support the members of the open-source community, and we do so on a purely voluntary basis.

Ethical companies that rely on open-source projects, such as Serenity, to run their business quite frequently try to do their part and support such projects via support contracts or training requests. This way they can get more specific value out of the products and help to ensure that they continue being maintained; that's how the ecosystem works.

If your company is asking for a specific bug fix or enhancement, but don't want to pay for the time it takes to implement it, how is that different from expecting someone to work for free?

r2d2-github commented 3 years ago

Hi @wakaleo my company is not asking for this fix. I am implementing Serenity BDD as a QA framework for my company projects, and I am only trying to do my job as a tester. Apologies if I have made any wrong impression here.

r2d2-github commented 3 years ago

Hi @wakaleo , this issue is now resolved after made changes in the pom.xml file for the Maven Failsafe plugin configuration as below. There is no defect in Serenity BDD.

<artifactId>maven-failsafe-plugin</artifactId>
 <version>${maven.failsafe-plugin.version}</version>
        <configuration>
          <includes>
            <include>**/*.java</include>
          </includes>
          <argLine>-Xmx512m</argLine>
          <parallel>classes</parallel>
          <threadCount>1</threadCount>
          <perCoreThreadCount>true</perCoreThreadCount>
        </configuration>

For some reason, I have not paid any attention to this section after drawing my project base framework from the Serenity starter repository. Thank you so much again for your time.