Attempting to execute a selenium mocha test to verify the title of Google's website. The setup involves Web.js and WebTest.js classes. Uncertain if proceeding in the correct manner.
Web.js
const {Builder, By, Key, until, WebElement} = require('selenium-webdriver');
var driver = new Builder().forBrowser('internet explorer').build();
var url = 'https://www.google.com/';
function Web() {
var promise = new Promise(function(resolve,reject){
return driver.get(url);
}).then(function(title) {
var title;
title = driver.getTitle().toString();
return title;
}).catch(function(err){
console.log(err);
});
return title;
}
Web.prototype.getTitle = function (title) {
var title = Web();
while (title == null){
title = Web();
}
return (title);
}
module.exports.Web = Web;
WebTest.js
assert = require("assert");
Web = require("../Web.js").Web
describe("A web function", function () {
describe("getting google's title", function () {
it("should return Google", function () {
var result = new Web().getTitle();
assert.equal("Google", result, "But the string " + result + " was returned instead");
});
});
});
Encountering the error "ReferenceError: title is not defined" indicating a potential scope issue, seeking guidance on resolving this matter effectively.
Your assistance would be greatly appreciated.