xxxxxxxxxx// enter the test data herevar grossAmount = 121.84// compute taxvar taxPercent = 0.06 // 6% expressed in decimalsvar expectedTaxAmount = grossAmount * taxPercent // compute tax amountexpectedTaxAmount = (expectedTaxAmount).toFixed(2) // round to 2 decimal places// go to our test web pageI.goTo("https://example.uilicious.com/gst_calculator.html")// enter the gross amountI.fill("gross amount", "" + grossAmount)// grab the value of the tax amount from the webpagevar TAX_AMOUNT_INPUT_FIELD = "#tax-amount"var actualTaxAmount = I.getValue(TAX_AMOUNT_INPUT_FIELD) // use I.getValue to read the value from an input field and store it to a variable `actualTaxAmount`// assert the value of the fieldTEST.assert( expectedTaxAmount === actualTaxAmount, // condition that we want to test `Expect tax to be ${expectedTaxAmount}, got ${actualTaxAmount}.`)// TEST.assert is a short-hand for writing the following:/*if(expectedTaxAmount === actualTaxAmount){ TEST.log.success(`Expect tax to be ${expectedTaxAmount}, got ${actualTaxAmount}.`)} else { TEST.log.fail(`Expect tax to be ${expectedTaxAmount}, got ${actualTaxAmount}.`)}*/Hi, I'm TAMI (Test Authoring Machine Intelligence).
Let me assist you in writing a test. Tell me a scenario to test, and I’ll write the test script for you!