Giter VIP home page Giter VIP logo

salesforce / codeceptjs-bdd Goto Github PK

View Code? Open in Web Editor NEW
44.0 7.0 14.0 53.92 MB

Javascript BDD UI Automation Framework. Exclusive LWC Shadow DOM Support. Playwright, Webdriver.io, Appium, Saucelabs.

Home Page: https://gkushang.github.io/

License: MIT License

JavaScript 93.61% Dockerfile 0.16% Gherkin 0.79% Shell 1.39% SCSS 2.04% TypeScript 1.61% Batchfile 0.40%
bdd codeceptjs-bdd parallel saucelabs assertions lwc salesforce shadow-dom salesforce-automation webcomponents

codeceptjs-bdd's Introduction

UI/API Test Automation Framework: WebdriverIO & Playwright with Cucumber & Mocha-stylig features/scenarios

CircleCI lerna License

  • Webdriver and Playwright parity: Write one test, Run on both drivers
  • BDD Cucumber and traditional Mocha-styled
  • SauceLabs and Selenoid integrations
  • Applitools, Appium integrations
  • Ease of Automating Salesforce Apps
    • Exclusive Shadow DOM support for LWC/LWR applications, WebComponents
    • WebdriverIO parity with Playwright to work with Shadow Elements
  • and many more features

Get Started

One line Setup,

npx create-codeceptjs-bdd-tests

Node 16 is required!

This Interactive CLI walks you through the step-step setup. It will setup,

  • Executions on both Webdriver & Playwright.
  • Create the framework structure with page objects, helpers, plugins, test env files etc.
  • Integrate Sauce Labs with framework
  • Provides default BDD & Mocha-style example scenarios to start with
  • Setup Parallel executions, and many more

Above command will also add Webdriver parity with Playwright to work with Shadow elements.

Example of out-of-the-box ShadowDOM support for WebComponents (LWC for Salesforce) & Applitools

Take a look at here

Execute

Webdriver
yarn acceptance --profile webdriver:chrome
Playwright
yarn acceptance --profile playwright:chrome
yarn acceptance --profile playwright:safari
yarn acceptance --profile playwright:firefox
yarn acceptance --profile playwright:google:chrome
Mobile or Tablets
yarn acceptance --profile device:'iPhone 11':safari

List of devices

Sauce Labs
yarn acceptance --profile sauce:chrome
yarn acceptance --profile sauce:"macOS 11.00":firefox:80
Parallel
yarn acceptance:parallel --profile playwright:chrome
Headless
HEADLESS=true yarn acceptance:parallel --profile playwright:chrome
For more info about the framework visit CodeceptJS BDD Docs & https://codecept.io/

Ease of working with Shadow Elements. Webdriver & Playwright Parity

Assuming you've enabled the Shadow DOM Support thru the CLI framework setup.

Let's say you want to fill-field on the Shadow element on this Lighting Web Components page: https://recipes.lwc.dev/. You aren't required to provide the DOM Hierarchy in this framework and still, it will find the elements thru Webdriver (Playwright has default support). Meaning, it provides the Playwright parity with Webdriver.

Means, same tests can run on both: Webdriver & Playwright.

So, all you need to provide unique CSS as shown below,

I.fillField('ui-input input','codeceptjs-bdd')

There may be cases that doesn't require you to deal with Shadow Element, e.g. plain login page, you can disable the Shadow Locators finder by providing CSS objects, e.g.

I.fillField({css: 'div.username'},'myusername');
I.fillField({css: 'div.password'},'******');

Have any questions? Join Slack community for more help

Slack Chat and join channel #codeceptjs-bdd for any specific questions about this framework

๐Ÿšš Changelog

Link to Changelog

๐ŸŽฅ How to Videos

YouTube How To Videos

Contributors

Thanks goes to these wonderful people who are and will have contributing to this awesome project!

codeceptjs-bdd's People

Contributors

abkap02 avatar andre-becker avatar cthorsen31 avatar dependabot[bot] avatar dominikdary avatar gkushang avatar limingli0707 avatar lorsatti avatar meghasfdc avatar ns-mnawaz avatar shikhar91939 avatar snyk-bot avatar svc-scm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

codeceptjs-bdd's Issues

Guide on Using With GitHub Actions

Hello, I've been trying to get a sensible working solution for end-to-end testing within Salesforce and have hit many roadblocks.

I had a version of code where I could reliably use the Travis CI free plan and Cypress to test the older VisualForce/Lightning UIs, but then came LWC and the terrible Shadow DOM. Also, then Travis CI stopped providing an open-source tier so I had to go back to GitHub Actions...and then the Salesforce Trailhead/docs to get Travis CI and the token, etc. working were removed.

So, now I am glad to find this solution which I can use locally just fine. However, I can't seem to get the JWT auth flow working on GitHub Actions. Since this project looks to be the defacto/future way to do E2E tests with LWC and Salesforce, I'm hoping a guide on doing this in GitHub, also Salesforce recommended, can be added to the docs.

I think Salesforce has a deal with CircleCI or something...but I can be of assistance in creating such a guide for GitHub Actions. I have a sample repo and current "To access this page, you have to log in to Salesforce." errors in logs.

So my three questions:

  • Is this the defacto way to do E2E testing in Salesforce going forward? Or at least Salesforce will support testing LWC (non-unit tests) through this project?
  • Is there a recommended way to use this project on CI platforms, specifically GitHub Actions/Workflows?
  • Is this the best way to "log in" during an E2E test? cypress-io/cypress#2367 (comment)

Sorry to ask these questions in a generic issue, and please point me to a better forum, if the discussion should not be on within GitHub issues.

Not able to run tests against selenoid

Steps to reproduce

  1. Generate tests via npx create-codeceptjs-bdd-tests
  2. Download Selenoid Configuration Manager from https://github.com/aerokube/cm/releases/tag/1.7.2
  3. Start selenoid via ./cm selenoid start --vnc --port 4445
  4. Set
# SELENOID OPTIONS
HUB_BASE_HOST = localhost
HUB_PORT = 4445

in codecept.env
4. Start tests via yarn acceptance --profile selenoid:chrome:88 --grep @smoke --verbose
5. Getting output:

๐Ÿš€ ๐Ÿš€ ๐Ÿš€   Codeceptjs-BDD Acceptance Tests   ๐Ÿš€ ๐Ÿš€ ๐Ÿš€ 

๐ŸŒ [docs] gkushang.github.io [repository] github.com/salesforce/codeceptjs-bdd

๐ŸŒŸ  Launching 'selenoid:chrome:88' on Webdriver.

๐ŸŒฅ๏ธ  Tests are running on : Selenoid {"browser":"chrome","version":"88"}

Webdriver: {"url":"https://github.com","browser":"chrome","smartWait":10000,"waitForTimeout":15000,"restart":true,"acceptInsecureCerts":true,"protocol":"http","host":"localhost","port":4445,"path":"/wd/hub","desiredCapabilities":{"acceptInsecureCerts":true,"selenoid:options":{"browserName":"chrome","version":"88","enableVNC":true,"enableVideo":false,"screenResolution":"1280x1024x24"}}}

๐Ÿ—‘๏ธ  cleaning report dir "/Users/lorenzoo/git/codeceptjs-bdd-test/tests/acceptance/report" ...

CodeceptJS v3.0.2
Using test root "/Users/lorenzoo/git/codeceptjs-bdd-test"
Helpers: Driver_commands, custom_methods, REST, WebDriver
Plugins: screenshotOnFail, allure, retryFailedStep, tryTo

Login Tests (mocha) --
    [1]  Starting recording promises
  Fred logs in successfully @login_mocha @smoke
    [1] Error | Error: Can't connect to WebDriver.
Error: Failed to create session.
Requested environment is not available

Please make sure Selenium Server (ChromeDriver or PhantomJS) is running and accessible
  โœ– "before each" hook: codeceptjs.before for "Fred logs in successfully @login_mocha @smoke" in 39ms
    [1] Error | Error: Can't connect to WebDriver.
Error: Failed to create session.
Requested environment is not available

Please make sure Selenium Server (ChromeDriver or PhantomJS) is running and accessible
Error: Can't connect to WebDriver.
Error: Failed to create session.
Requested environment is not available

Please make sure Selenium Server (ChromeDriver or PhantomJS) is running and accessible

-- FAILURES:

  1) Login Tests (mocha)
       "before each" hook: codeceptjs.before for "Fred logs in successfully @login_mocha @smoke":
     Can't connect to WebDriver.
Error: Failed to create session.
Requested environment is not available

Please make sure Selenium Server (ChromeDriver or PhantomJS) is running and accessible
  Error: Failed to create session.
  Requested environment is not available
      at Object.startWebDriverSession (node_modules/webdriver/build/utils.js:34:15)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)
      at Function.newSession (node_modules/webdriver/build/index.js:35:45)
      at Object.exports.remote (node_modules/webdriverio/build/index.js:53:22)
      at WebDriver._startBrowser (node_modules/codeceptjs/lib/helper/WebDriver.js:516:24)

``

Wrong JSON content

Hello! I'm getting this error when running commmand on windows:
npx create-codeceptjs-bdd-tests

===============================
๐Ÿš€ Installing dependencies...

yarn add v1.22.19
error An unexpected error occurred: "C:\Salesforce\test\codeceptjs-bdd\package.json: Expected ',' or '}' after property value in JSON at position 779".
info If you think this is a bug, please open a bug report with the information provided in "C:\Salesforce\test\codeceptjs-bdd\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
C:\Users\lolg\AppData\Local\npm-cache_npx\bd4f35f9a4c924f0\node_modules\create-codeceptjs-bdd-tests\cli\update.package.js:27
throw new Error('Yarn command failed.');
^

Error: Yarn command failed.
at exports.installDependencies (C:\Users\lolg\AppData\Local\npm-cache_npx\bd4f35f9a4c924f0\node_modules\create-codeceptjs-bdd-tests\cli\update.package.js:27:15)
at run (C:\Users\lolg\AppData\Local\npm-cache_npx\bd4f35f9a4c924f0\node_modules\create-codeceptjs-bdd-tests\cli\create.js:150:5)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.3.0

log file yarn-error.log is attached.

yarn-error.log

Error seems to be on double quotes on package.json:
image

thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.