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
- Node > 10
git clone email@example.com:gkushang/codeceptjs-bdd.gitcd codeceptjs-bdd/packages/codeceptjs-lwc-exampleyarn
Run Acceptance Tests
This example automates the
Hello Binding component from the LWC Recipes Page.
@hello_binding @lwc_recipesFeature: HelloBinding from Salesforce LWC RecipesAs a LWC developerI want to be able to automate the LWC Shadow Dom ComponentsSo that I can quickly create my UI Automated Suite using Selenium=> LWC Recipe Page: https://recipes.lwc.dev/#hello@hello_binding_componentScenario: Fred successfully types in and verifies the title in Hello Binding LWC ComponentWhen Fred types "Kushang Gajjar" into the Hello Binding ComponentThen 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
// input field on helloBinding componentinputField:
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