diff --git a/exercises/03_acceptance/cucumber/features/add_one.feature b/exercises/03_acceptance/cucumber/features/add_one.feature index 81684bf..f48f8e6 100644 --- a/exercises/03_acceptance/cucumber/features/add_one.feature +++ b/exercises/03_acceptance/cucumber/features/add_one.feature @@ -6,4 +6,11 @@ Feature: Adding Items When I add "bread" with the quantity "17" Then that data exists in memory - + Scenario: add item via webpage + Given The browser is open on the home page + When I enter "bread" in the "item" field + When I enter "42" in the "qty" field + When I click on the submit button + Then the heading should be "ToDo List" + Then the list should contain "1" row + Then the item should be "bread" \ No newline at end of file diff --git a/exercises/03_acceptance/cucumber/features/nextFeature.devel b/exercises/03_acceptance/cucumber/features/nextFeature.devel deleted file mode 100644 index 7479c16..0000000 --- a/exercises/03_acceptance/cucumber/features/nextFeature.devel +++ /dev/null @@ -1,10 +0,0 @@ -#When ready copy the code below into add_one.feature and implement it into add_one.steps.js. - - Scenario: add item via webpage - Given The browser is open on the home page - When I enter "bread" in the "item" field - When I enter "42" in the "qty" field - When I click on the submit button - Then the heading should be "ToDo List" - Then the list should contain "1" row - Then the item in row "1" should be "bread" \ No newline at end of file diff --git a/exercises/03_acceptance/cucumber/steps/add_one.steps.js b/exercises/03_acceptance/cucumber/steps/add_one.steps.js index ddcc60f..746bf74 100644 --- a/exercises/03_acceptance/cucumber/steps/add_one.steps.js +++ b/exercises/03_acceptance/cucumber/steps/add_one.steps.js @@ -23,15 +23,8 @@ const todo = require('../modules/todo.js') assert.equal(currentData.qty, 17) }); -/* -STARTING CODE TO HELP WITH "nextFeature.devel" - -Copy the contents of nextFeature.devel into add_one.feature, -then come back to this file and implement the features one by one. - -There is already some setup code, so you only need to focus on the tests. - - +// Scenario: add item via webpage +//Setup Code const puppeteer = require('puppeteer') const PAGE = 'http://localhost:8080' @@ -43,6 +36,11 @@ const delayMS = 5 let page let browser +let rows = -1 //test 6 && +//-1 because we don't count the heading row +let headingToCheck = "" //test 5 +let itemValue = "" //test 7 + async function initialize() { console.log("Launching browser") browser = await puppeteer.launch({ headless: true, slowMo: delayMS, args: ['--disable-gpu', `--no-sandbox`, '--disable-dev-shm-usage'] }) @@ -56,21 +54,47 @@ async function initialize() { } async function addToPage(field, value){ - // add puppeteer code - console.log("In development!") + await page.click("#" + field) //field represents the id attribute in html + await page.keyboard.type(value) } async function pressSubmit(){ - // add puppeteer code - console.log("In development!") + await page.click("#submit") +} + +async function parseHTML(html) +{ + let startOfHeading = 0 + for (let i = 0; i < html.length -4; i++) + { + let nextWord = html.slice(i, i+4) + if (nextWord == "