Skip to content

wdioWithCucumberTemplate-0001 - #5

Open
sharif-jobayed wants to merge 1 commit into
sj-mainfrom
wdioWithCucumberTemplate-0001
Open

wdioWithCucumberTemplate-0001#5
sharif-jobayed wants to merge 1 commit into
sj-mainfrom
wdioWithCucumberTemplate-0001

Conversation

@sharif-jobayed

Copy link
Copy Markdown
Owner

No description provided.

@sharif-jobayed sharif-jobayed self-assigned this Jul 20, 2025
@sharif-jobayed sharif-jobayed added the in progress The code is being worked on label Jul 20, 2025

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @sharif-jobayed, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request sets up a robust WebdriverIO and Cucumber-based test automation framework. It establishes core components such as a Page Object Model, BDD feature files with step definitions, and comprehensive WebdriverIO configurations, including Allure reporting. The aim is to provide a scalable and maintainable foundation for end-to-end test automation.

Highlights

  • Framework Initialization: This pull request initializes a WebdriverIO (WDIO) automation framework, configured to use Cucumber for Behavior-Driven Development (BDD).
  • Page Object Model (POM) Implementation: A foundational Page Object Model (POM) structure has been established, including BaseElement for common element interactions, BasePage for general page functionalities, and specific page classes like LoginPage.
  • BDD Feature and Step Definitions: A sample Cucumber feature file (LoginPage.feature) is introduced to demonstrate a login flow for SauceDemo, accompanied by corresponding step definitions (loginPageSteps.js) that interact with the POM.
  • Configuration and Data Management: The wdio.conf.js file is set up for WebdriverIO, integrating Cucumber and Allure reporting. Separate JSON files (appData.json, userData.json) are added for managing application-specific data and user credentials.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new WebdriverIO project with a Cucumber framework. While the structure shows promise, several critical issues need addressing to ensure the tests run correctly. These include syntax errors, incorrect imports, and undefined variables. Addressing these comments will result in a more robust and functional test automation setup.

Comment thread src/pages/homePage.js
@@ -0,0 +1,11 @@
import { } from '../framework/basePage.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Import BasePage to allow HomePage to inherit from it.

Suggested change
import { } from '../framework/basePage.js';
import { BasePage } from '../framework/basePage.js';

Comment thread src/pages/homePage.js
class HomePage extends BasePage {

constructor() {
super(pagePath, pageName);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The super() call requires the page path and name. Provide the correct values for the home page.

Suggested change
super(pagePath, pageName);
super('inventory.html', 'Home Page');

Comment on lines +53 to +56
Then(/^I should be redirected to the "Products" page$/, async () => {
await expect(ProductsPage.pageTitle).toBeDisplayed();
await expect(browser).toHaveUrlContaining('/inventory.html');
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This step definition has issues:

  1. It references ProductsPage, which is not defined or imported. Create and import a ProductsPage object.
  2. It uses expect-webdriverio assertions, while other steps use chai. Use chai for consistency.

Comment thread wdio.conf.js
Comment on lines +221 to +222
* Runs before a WebdriverIO command gets executed. {
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Remove the malformed comment and stray brace. This syntax error will prevent WebdriverIO from parsing the configuration file.

Comment thread package.json
"allure-commandline": "^2.34.1"
},
"scripts": {
"test": "npx wdio",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The test script should execute the tests using the configuration file. Update the script to npx wdio run wdio.conf.js.

    "test": "npx wdio run wdio.conf.js",

Comment thread .gitignore
# Dependency directories
node_modules/
jspm_packages/
package-lock.json

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It's generally a good practice to commit package-lock.json to ensure dependency version consistency across environments. Consider removing this line from .gitignore.

Comment on lines +67 to +76
try {
if (await this.isEnabled(timeout)) {
await this.getLocator().clearValue();
await this.getLocator().setValue(value);
} else {
console.warn(`${this.elementName} is not enabled`);
}
} catch (err) {
console.error(`Error clearing and typing value: ${err.message}`);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The isEnabled check is performed redundantly. Simplify the clearAndType method to improve readability and remove the unnecessary check.

			try {
				await this.getLocator().clearValue();
				await this.getLocator().setValue(value);
			} catch (err) {
				console.error(`Error clearing and typing value: ${err.message}`);
			}

class PageBuilder {

async getPage(pageName) {
const pn = await pageName.toLowerCase();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The await keyword is unnecessary here because toLowerCase() is synchronous. Remove await for clarity.

Suggested change
const pn = await pageName.toLowerCase();
const pn = pageName.toLowerCase();

import { Given, When, Then } from '@wdio/cucumber-framework';
import { assert } from 'chai';
import { readFileSync } from 'fs';
const userData = JSON.parse(readFileSync(new URL('../data/userData.json', import.meta.url)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The userData constant is currently unused. Remove the import to keep the code clean.


When(
/^I enter the username "(.*)" on "(.*)" page$/,
async (username, pageName) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The pageName parameter is not used. Remove it from the function signature to simplify the code.

Suggested change
async (username, pageName) => {
async (username) => {

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

Labels

in progress The code is being worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant