Can't Pass Tests: QA and Testing with Chai in a Headless Browser

Hey I’m having difficulty with the QA/Testing Challenges.

This is my code so far:

      /** Now it's your turn. Please don't use the keyword #example in the title. **/
      test('submit "surname" : "Colombo" - write your e2e test...', function(done) {
        browser.fill("surname", "Colombo").pressButton("submit", function() {
         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()''
        });
      });

// running tests
All tests should pass.
You should assert that the text inside the element ‘span#name’ is ‘Cristoforo’.
You should assert that the text inside the element ‘span#surname’ is ‘Colombo’.
You should assert that the element ‘span#dates’ exist and its count is 1.
// tests completed

My Code So Far

Can anyone help me?

2 Likes

@rebecca, try using single quote marks ' ' instead of double quote marks " " where you see assert

btw, what you’re getting in the LOGS for this test?

1 Like

Except the above, your code is ok for the test

same issue I replaced " " with ' '

@Advitya-sharma, submit your solution few times, it should work, if your internet connection is fine

passed one test currently

1 Like

@Advitya-sharma, now fill the last one

same is happening for last

Oh, I tried the single quotes but it doesn’t seem to be helping.

My logs are saying

TypeError: browser.fill(…).pressButton is not a function

Yay! Thank you! It worked!

Solution:


test('submit "surname" : "Colombo" - write your e2e test...', function(done) {
        browser.fill("surname", "Colombo");
        browser.pressButton("submit", function() {
          browser.assert.success();
          
          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()''
        });
      });
1 Like