As a beginner in test driven development using mocha, selenium, and chai, I am seeking feedback on whether my approach is correct. Below is an excerpt from my functional_tests.js file:
test.it('Hamid visits the first page of tests', function(){
// Hamid visits the home page of the test platform he heard about
driver.get('file:///home/marouane/Projects/iframe_test/test_template.html') ;
// he noticed the title and the header of the page mention Test Template
driver.getTitle().then(function(title){
expect(title).to.contain('Test Template');
});
driver.findElement(webdriver.By.tagName('h1')).then(function(element){
expect(element).to.contain('Test Template');
});
// he is invited to enter a URL for the page he wants to test
driver.findElement(webdriver.By.id('input-url'), function(element){
expect(element).to.equal('Enter a url');
});
Here is the html page I am testing:
<!DOCTYPE html>
<html>
<head>
<title>Test Template</title>
</head>
<body>
<h1></h1>
</body>
</html>
While expecting an assertion error on the second chai expectation, I encountered this error instead:
NoSuchElementError: Unable to locate element: {"method":"id","selector":"input-url"}.
I suspect I might be making a mistake and that the callback functions are being deferred.