Getting "no step matching" error when executing BDD based test
This is my .feature file Feature: Login to ASPEN
**Scenario Outline: Login to app with credentials
Given Hit the URL
Examples: |url | username | password | |http://test.abc.com | [email protected] | Password1@ |**
This is my .js file
const I = actor(); // Add in your custom step files
Given(/^Hit the URL "([^"]*)"$/, async function(url) { I.amOnPage(url); I.wait(5);
});
Given(/^Enter "([^"]*)"$/, async function(username){ I.fillField('#email',username); });
Given(/^Enter "([^"]*)"$/, async function(password){ I.fillField('#password',password); });
When('I click on login button', () => { I.click('#submit'); });
Then('On successful login result is user is navigated to the landing page', () => { I.see("My Protfolio"); });
I am getting this error
C:\bdd\tests>codeceptjs run --steps --features CodeceptJS v1.3.3 Using test root "C:\bdd\tests"
Login to ASPEN -- Login to ASPEN with credentials {"url":"http://test.aspenengine.com","username":"[email protected]","password":"Password1@"} × FAILED in 280ms
-- FAILURES:
- Login to ASPEN Login to app with credentials {"url":"http://test.abc.com","username":"[email protected]","password":"Password1@"}: No steps matching "Hit the URL http://test.aspenengine.com"
Run with --verbose flag to see NodeJS stacktrace
Could you try this
Given(/^Hit the "([^"]*)"$/, async function(url) { I.amOnPage(url); I.wait(5); });
@yupadhye The way you wrote your cucumber file tells me that you forgot to pass in the values as well. Try:
Feature: Login to ASPEN
**Scenario Outline: Login to app with credentials
Given Hit the URL "<url>"
Given Enter "<username>"
Given Enter "<password>"
When I click on login button
Then On successful login result is user is navigated to the landing page
Examples:
|url | username | password |
|http://test.abc.com | [email protected] | Password1@ |**
Similar issue
Scenario Outline: all vendors @test
Given the user is on the "New Invoice" page
When the invoice has header info <VendorName> and <InvoiceNumber>
And entered line item with the information
| Quantity | CostPer |
| 10 | ?2.00 |
And Leaving "Account" field blank
And Click "Create" at the bottom of the page
Then User should see an Error message "The following required fields are missing for items: Account."
Examples:
| VendorName | InvoiceNumber |
| 24 Locks | 261118_001 |
When(/the invoice has header info (\.+) and (\.+)/, async (VendorName,InvoiceNumber) => {
// From "features/Invoice.feature" {"line":14,"column":17}
// take values
const _VendorName = VendorName;
var date = new Date();
const InvoiceName = InvoiceNumber;
var _invoiceName = `${InvoiceName+'-'+date.getDate()+'-'+date.getHours()+'-'+date.getMinutes()+'-'+'QAT'}`
await Promise.all([
I.click('create an invoice without a document.'),
//I.see('Invoice Details'),
I.waitForNavigation({ waitUntil: 'domcontentloaded' }),
I.waitForText('Invoice Details', 1),
I.fillField('inv-vendor-name', _VendorName),
I.pressKey('Tab'),
I.waitForVisible('.inv-po-number-input-0',1)
]);
await Promise.all([
I.pressKey('Tab'),
I.waitForInvisible('.inv-po-number-input-0',1),
I.fillField('inv-invoice-number', _invoiceName)
]);
});
Error is get No steps matching "the invoice has header info 24 Locks and 261118_001"
Version i am using - 1.4.5
Hey @innovation-ap,
Interesting approach you have there. I personally have never seen or heard of an approach like this actually working. What confuses me and probably also cucumber is your feature steps.
Scenario Outline works with Examples tables, however the value table passed in for step 3 does not require scenario outline.
You can try changing your cucumber sentenced in the method declaration as such and see if it works as expected:
When("the invoice has header info {stringInDoubleQuotes} and {stringInDoubleQuotes}", async (VendorName,InvoiceNumber) => {
your feature step would need to look like this:
When the invoice has header info "<VendorName>" and "<InvoiceNumber>"
Let me know if this fixed your issue.
@yupadhye The way you wrote your cucumber file tells me that you forgot to pass in the values as well. Try:
Feature: Login to ASPEN **Scenario Outline: Login to app with credentials Given Hit the URL "<url>" Given Enter "<username>" Given Enter "<password>" When I click on login button Then On successful login result is user is navigated to the landing page Examples: |url | username | password | |http://test.abc.com | [email protected] | Password1@ |**
Can someone provide the step definition for this Scenario Outline. Am trying to implement codeceptjs and struck at this stage ?
I got the same trouble and still stuck there
This is how I solved:
Feature:
Then I should see the following main menu items "<MenuItems>"
Examples:
| MenuItems |
| Menu One |
| Menu Two |
Step:
Then('I should see following main menu items {string}', (mainMenuItem) => {
I.see(mainMenuItem);
}