diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..495ceb8 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,34 @@ +# Starter pipeline +# Start with a minimal pipeline that you can customize to build and deploy your code. +# Add steps that build, run tests, deploy, and more: +# https://aka.ms/yaml + +trigger: +- main + +pool: + vmImage: ubuntu-latest + +steps: +- script: echo Hello, world! + displayName: 'Run a one-line script' + +- task: DownloadSecureFile@1 + inputs: + secureFile: 'browserstack-node-sdk-1.34.33.tgz' # Replace with the name of your secure file + name: downloadSecureFileStep + +- script: | + ls -al + printenv + npm i + npm uninstall browserstack-node-sdk + npm i "$(downloadSecureFileStep.secureFilePath)" + npx browserstack-node-sdk --version + echo "RUNNING TEST" + echo $BROWSERSTACK_USERNAME + npm run sample-test + env: + BROWSERSTACK_USERNAME: $(BROWSERSTACK_USERNAME) + BROWSERSTACK_ACCESS_KEY: ${BROWSERSTACK_ACCESS_KEY} + displayName: 'Run a multi-line script' \ No newline at end of file diff --git a/browserstack.yml b/browserstack.yml index 931609d..ad03d3c 100644 --- a/browserstack.yml +++ b/browserstack.yml @@ -11,9 +11,9 @@ accessKey: YOUR_ACCESS_KEY # ====================== # The following capabilities are used to set up reporting on BrowserStack: # Set 'projectName' to the name of your project. Example, Marketing Website -projectName: BrowserStack Samples +projectName: az-pw-test # Set `buildName` as the name of the job / testsuite being run -buildName: browserstack build +buildName: az-pw-test # `buildIdentifier` is a unique id to differentiate every execution that gets appended to # buildName. Choose your buildIdentifier format from the available expressions: # ${BUILD_NUMBER} (Default): Generates an incremental counter with every execution @@ -31,14 +31,14 @@ platforms: osVersion: 11 browserName: chrome browserVersion: latest - - os: OS X - osVersion: Ventura - browserName: playwright-webkit - browserVersion: latest - - os: Windows - osVersion: 11 - browserName: playwright-firefox - browserVersion: latest + # - os: OS X + # osVersion: Ventura + # browserName: playwright-webkit + # browserVersion: latest + # - os: Windows + # osVersion: 11 + # browserName: playwright-firefox + # browserVersion: latest # ======================= # Parallels per Platform @@ -57,7 +57,7 @@ parallelsPerPlatform: 1 # ========================================== # Set browserStackLocal to true if your website under test is not accessible publicly over the internet # Learn more about how BrowserStack Local works here -> https://www.browserstack.com/docs/automate/selenium/local-testing-introduction -browserstackLocal: true # (Default false) +browserstackLocal: false # (Default false) # browserStackLocalOptions: # Options to be passed to BrowserStack local in-case of advanced configurations # localIdentifier: # (Default: null) Needed if you need to run multiple instances of local. diff --git a/playwright.config.js b/playwright.config.js index 0f3a2f4..78fa668 100644 --- a/playwright.config.js +++ b/playwright.config.js @@ -1,7 +1,7 @@ // This is a sample config for what users might be running locally const config = { testDir: './tests', - testMatch: '**/bstack_test*.js', + testMatch: '**/bstack_test_add*.js', /* Maximum time one test can run for. */ timeout: 90 * 1000, diff --git a/tests/bstack_test_add_to_cart.js b/tests/bstack_test_add_to_cart.js index a6b55a8..e305c65 100644 --- a/tests/bstack_test_add_to_cart.js +++ b/tests/bstack_test_add_to_cart.js @@ -16,3 +16,20 @@ test('BStackDemo test add to cart', async ({ page }) => { // check if product in cart is same as one added expect(productInCart).toEqual(productToAdd); }); + +test('BStackDemo test add to cart failed', async ({ page }) => { + // visit the site + await page.goto('https://bstackdemo.com/'); + + // get name of product we want to add to cart\ + const productToAdd = await page.locator('#\\33 > p').textContent(); + + // click on add to cart + await page.click('#\\33 > .shelf-item__buy-btn'); + + // get name of item in cart + const productInCart = await page.textContent('#__next > div > div > div.float-cart.float-cart--open > div.float-cart__content > div.float-cart__shelf-container > div > div.shelf-item__details > p.title'); + + // check if product in cart is same as one added + expect(productInCart).toEqual("failed test"); +}); \ No newline at end of file