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: Add keywords (Given, When, Then) to html report #69

Closed
vitalets opened this issue Nov 10, 2023 · 10 comments
Closed

Feature: Add keywords (Given, When, Then) to html report #69

vitalets opened this issue Nov 10, 2023 · 10 comments
Labels
enhancement New feature or request

Comments

@vitalets
Copy link
Owner

The problem
Currently html-report does not contain keywords (Given, When, Then):

It should be:

Given I am on Playwright home page
When I click link "Get started"
Then I see in title "Installation"

A solution
Pass keywords to Playwright steps to display them in report.
Use exactly the same keywords as used in feature file (e.g. don't convert And -> Given).
Handle i18n keywords.

Keep in mind Cucumber reporters: #9

@vitalets vitalets added the enhancement New feature or request label Nov 10, 2023
@meeranharish
Copy link

meeranharish commented Nov 14, 2023

@vitalets
Hi,
You have proposed an work around to pass keywords to the steps. Can we then use the steps in different context ?

Eg:
Given User logs out
When User login
Then User access main menu

Eg2:
Given User login
When User logs out
Then User cannot access main menu

In these examples we used the same step but in different context 'given' in eg1 and 'when' in eg 2
Can we use same step implementation for them if we pass the keyword to the step definition name?

Or did i misunderstood you?

Thanks

@vitalets
Copy link
Owner Author

Hi @meeranharish
Yes, scenarios are relax on keywords in step definitions, e.g. step defined with Given can be used also with When or Then.
The purpose of this issue is to display steps in html-report with corresponding keyword. For your example report should show exactly strings that you typed in scenario:

Given User logs out
When User login
Then User access main menu

Given User login
When User logs out
Then User cannot access main menu

Instead of current behavior:

User logs out
User login
User access main menu

User login
User logs out
User cannot access main menu

@meeranharish
Copy link

Thanks for the response. Yes, the steps are not tied to keywords but only that we might miss the keyword in the report.
As you proposed this
"
A solution
Pass keywords to Playwright steps to display them in report.
"
I felt that might bring in the restriction for the sake of reporting, right?

@vitalets
Copy link
Owner Author

I felt that might bring in the restriction for the sake of reporting, right?

Got it. No, steps will not be restricted to keywords.

@meeranharish
Copy link

@vitalets
whats your suggested way to pass the keywords to the step?

@vitalets
Copy link
Owner Author

whats your suggested way to pass the keywords to the step?

This is just internal implementation details. Nothing will change from the usage point.
Currently we actually pass keyword to the step - via Given / When / Then calls in generated files:

    await Given("State 1");
    await When("Action 1");
    await Then("Assertion 1");

@meeranharish
Copy link

whats your suggested way to pass the keywords to the step?

This is just internal implementation details. Nothing will change from the usage point. Currently we actually pass keyword to the step - via Given / When / Then calls in generated files:

    await Given("State 1");
    await When("Action 1");
    await Then("Assertion 1");

Is this sufficient enough to get the corresponding keywords in the html report for each step? Currently we don't get right?

@vitalets
Copy link
Owner Author

Is this sufficient enough to get the corresponding keywords in the html report for each step? Currently we don't get right?

Yes, it should be sufficient. There are also And / But calls for corresponding step texts. So I want to get html-report as close as possible to what we have in feature files.

@meeranharish
Copy link

Looking forward :)

vitalets added a commit that referenced this issue Nov 20, 2023
@vitalets
Copy link
Owner Author

Released in 5.5.0 for English keywords.
Now html report is the following:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants