# freeCodeCamp Challenge Guide: Run Functional Tests using a Headless Browser

**URL:** <https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-run-functional-tests-using-a-headless-browser/301595>\
**Category:** freeCodeCamp Contributors\
**Tags:** guide\
**Created:** [August 3, 2019, 1:21pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-run-functional-tests-using-a-headless-browser/301595 "2019-08-03T13:21:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![camperbot](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/camperbot/32/18364_2.png) [@camperbot](https://forum.freecodecamp.org/u/camperbot)\
**Post date:** [August 3, 2019, 1:21pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-run-functional-tests-using-a-headless-browser/301595/1 "2019-08-03T13:21:47Z")

</div>

# [Run Functional Tests using a Headless Browser](https://www.freecodecamp.org/learn/quality-assurance/quality-assurance-and-testing-with-chai/run-functional-tests-using-a-headless-browser)

* * *

## Problem Explanation

To begin, open the file “tests/2\_functional\_tests.js” and locate the browser based tests.

Change the Browser.site link to the current URL of your project if you are completing this challenge online. If you are using a local development environment, replace the line with `Browser.localhost('example.com', (process.env.PORT || 3000));`.

Find test ‘submit “surname” : “Colombo” - write your e2e test…’ and read the instructions to determine how to pass this challenge.

* * *

## Hints

### Hint 1

Using the example above, look at how the assertions are making comparisons between the expected and actual values of the response.

### Hint 2

All assertions should be browser.assert in order to correctly pass.

### Hint 3

Replace the `assert.fail()` statement with your own tests based on the instructions in the comments. Check the example above for syntax if you get stuck.

### Hint 4

Check the tests on the challenge page for expected values.

* * *

## Solutions

> **Solution 1 (Click to Show/Hide)**
>
> ```js
> test('submit "surname" : "Colombo" - write your e2e test...', function(done) {
> // fill the form...
> // then submit it pressing 'submit' button.
> //
> // in the callback...
> // assert that status is OK 200
> // assert that the text inside the element 'span#name' is 'Cristoforo'
> // assert that the text inside the element 'span#surname' is 'Colombo'
> // assert that the element(s) 'span#dates' exist and their count is 1
> browser.fill('surname', 'Colombo').pressButton('submit', function() {
> /**YOUR TESTS HERE, Don't forget to remove assert.fail()**/
> 
> // pressButton is Async. Waits for the ajax call to complete...
> 
> // assert that status is OK 200
> browser.assert.success();
> // assert that the text inside the element 'span#name' is 'Cristoforo'
> browser.assert.text('span#name', 'Cristoforo');
> // assert that the text inside the element 'span#surname' is 'Colombo'
> browser.assert.text('span#surname', 'Colombo');
> // assert that the element(s) 'span#dates' exist and their count is 1
> browser.assert.element('span#dates', 1);
> 
> done(); // It's an async test, so we have to call 'done()''
> });
> });
> 
> ```

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 8, 2025, 3:58pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-run-functional-tests-using-a-headless-browser/301595/2 "2025-01-08T15:58:00Z")

</div>

Closed on January 8, 2025, 3:58pm UTC


