Salesforce's LWC E2E Automation Example
This repository automates the LWC Recipes page using Selenium WebDriver thru Codeceptjs-BDD framework. It uses Cucumber BDD Feature files to automate the LWC Features. You can also choose to automate with Mocha styles traditional tests. For more info, take a look at Codeceptjs-BDD Docs.
This example automates the HelloBinding LWC Component on LWC Recipe - https://recipes.lwc.dev/#hello
Pre-requisite
- Yarn
- Node > 10
Getting Started
git clone git@github.com:gkushang/codeceptjs-bdd.gitcd codeceptjs-bdd/packages/codeceptjs-lwc-exampleyarn
Run Acceptance Tests
yarn acceptance
HTML Report
yarn acceptance:report
Feature
This example automates the Hello Binding
component from the LWC Recipes Page.
@hello_binding @lwc_recipesFeature: HelloBinding from Salesforce LWC Recipes As a LWC developer I want to be able to automate the LWC Shadow Dom Components So that I can quickly create my UI Automated Suite using Selenium => LWC Recipe Page: https://recipes.lwc.dev/#hello @hello_binding_component Scenario: Fred successfully types in and verifies the title in Hello Binding LWC Component When Fred types "Kushang Gajjar" into the Hello Binding Component Then he sees the title is updated accordingly
Locating LWC Element
The work is still in-progress for the changes to be accepted at CodeceptJS. Here is the proposal on how to select the element when it's chained with custom elements.
In the page object, you can define your locators as a special shadow
locator.
// input field on helloBinding component inputField:
Page Objects
Since it inherits the elements from the host/parent, you can define your Page Objects as a Class and take benefits of inheritance in your page objects. This makes a lot of your code/locators Re-usable across the app.
class HelloBinding extends LightingComponent