{"id":20721621,"url":"https://github.com/fslev/cucumber-selenium-tutorial","last_synced_at":"2026-04-21T15:02:15.141Z","repository":{"id":51539773,"uuid":"390268328","full_name":"fslev/cucumber-selenium-tutorial","owner":"fslev","description":"How to test a website with Cucumber and Selenium","archived":false,"fork":false,"pushed_at":"2023-12-05T09:07:35.000Z","size":174,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-17T22:43:42.971Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fslev.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-07-28T08:10:03.000Z","updated_at":"2022-08-09T09:50:50.000Z","dependencies_parsed_at":"2023-12-05T10:28:28.245Z","dependency_job_id":"637a1202-c903-4218-80e0-388d805bfb60","html_url":"https://github.com/fslev/cucumber-selenium-tutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fslev%2Fcucumber-selenium-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fslev%2Fcucumber-selenium-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fslev%2Fcucumber-selenium-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fslev%2Fcucumber-selenium-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fslev","download_url":"https://codeload.github.com/fslev/cucumber-selenium-tutorial/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242995915,"owners_count":20218829,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T03:28:44.206Z","updated_at":"2026-04-21T15:02:10.109Z","avatar_url":"https://github.com/fslev.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cucumber Selenium tutorial\nHow to test a website user interface using Cucumber and Selenium\n\n## Dependencies used\n- [**selenium-jutils**](https://github.com/fslev/selenium-jutils)\n- [**cucumber-jutils**](https://github.com/fslev/cucumber-jutils)\n- Selenium and Cucumber for java\n- Lombok\n\n## How to run\nStart Selenium Grid via _docker-compose_ from _src/test/resources/selenium_:  \n```\ndocker-compose -f selenium-grid.yml up\n```\nRun tests with Maven and generate reports:  \n```\nmvn clean verify -Plocal,html-report -Dtags=@ui -Dconcurrent=true -Dbrowser.type=chrome -Dthreads=4\n```\n\n## Application \nThe test application is a Grocery web page:  \n\u003cimg src=\"grocery_app.png\"/\u003e\n\n## Page object models\n_BasePage.java_:  \n```java\npublic abstract class BasePage {\n    \n    protected BasePage(WebDriver driver) {\n        this.driver = driver;\n        PageFactory.initElements(new FieldContextDecorator(new ElementContextLocatorFactory(driver, Duration.ofSeconds(10),\n                Collections.singletonList(StaleElementReferenceException.class))), this);\n    }\n```\n_GroceryPage.java_:\n```java\n@ScenarioScoped\n@Getter\npublic class GroceryPage extends BasePage {\n\n    @FindBy(xpath = \"//app-root//app-list\")\n    private GroceryListContext groceryListContext;\n```\n_GroceryListContext.java_:\n```java\npublic class GroceryListContext extends WebContext {\n\n    @FindBy(xpath = \".//input[@type='text']\")\n    private WebElement groceryInput;\n\n    @FindBy(xpath = \".//button[text()='Add']\")\n    private WebElement groceryAddButton;\n\n    @FindBy(xpath = \".//ul/li\")\n    @Getter\n    private List\u003cItem\u003e groceryItemList;\n```\n## Cucumber step definitions\n\n_GroceryListSteps.java_:\n```java\n@ScenarioScoped\npublic class GroceryListSteps extends BaseScenario {\n\n    @Inject\n    private GroceryPage groceryPage;\n\n    @When(\"Go to grocery list tab\")\n    public void goToGroceryListTab() {\n        groceryPage.getGroceryListLink().click();\n    }\n\n    @When(\"Check grocery list size={}\")\n    public void checkGroceryListSize(int size) {\n        assertEquals(size, groceryPage.getGroceryListContext().getGroceryItemList().size());\n    }\n\n    @When(\"Add grocery item with name={}\")\n    public void addGroceryItem(String name) {\n        groceryPage.getGroceryListContext().addGroceryItem(name);\n    }\n```\n\n## Features\n\n_Grocery.feature_:  \n```gherkin\n@ui\n@local @prod\n@groceryList\nFeature: Grocery List feature\n\n  Scenario: Add grocery item\n    * Go to grocery list tab\n    * Check grocery list size=6\n    * var itemName=\"Custom grocery item1\"\n    * Add grocery item with name=#[itemName]\n    * Check grocery list size=7\n    * Check grocery list contains item with name=#[itemName]\n```\n\n## Cucumber Test Report\n\n\u003cimg src=\"report.png\"/\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffslev%2Fcucumber-selenium-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffslev%2Fcucumber-selenium-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffslev%2Fcucumber-selenium-tutorial/lists"}