selenium
selenium copied to clipboard
Elementfactory in selenium pageobject nodeJS
const webdriver = require('selenium-webdriver');
const config = require('../setup/config');
const server_url = 'http://' + config.server + ':' + config.port + '/wd/hub';
const test = require('selenium-webdriver/testing');
const pageNav = require('selenium-pageobject').PageNavigator;
const lpo = require('../pages/loginpo');
const login_data = require('../input data/login');
let po = require('selenium-pageobject');
describe('hello', function (done) {
let driver;
/**
* Launch the browser
* Initialise driver
*/
before(function (done) {
driver = new webdriver.Builder().forBrowser('chrome')
.usingServer(server_url).build();
driver.get(config.url).then(done());
po.elements.ElementFactory(driver);
});
/**
* Login to website
*/
it('Hello testing', function (done) {
let pageNavigator = new pageNav({ driver: driver });
let myPage = new lpo(driver);
pageNavigator.visit(config.url).then(function () {
myPage.userLogin(driver).then(function () {
// expect something
console.log('Pass');
})
}).then(done());
});
after(function (done) {
driver.quit().then(done());
});
});
I m running this code using mocha and getting the below error:
Error: The driver must be specified for the ElementFactory to work
at new ElementFactory (D:\Clientela automation\Cartier with node\node_modules\selenium-pageobject\lib\elements\elementfactory.js:7:15)
at Object.Element (D:\Clientela automation\Cartier with node\node_modules\selenium-pageobject\lib\elements\element.js:10:15)
at Object.TextBox (D:\Clientela automation\Cartier with node\node_modules\selenium-pageobject\lib\elements\textbox.js:10:16)
at new userLogin (D:\Clientela automation\Cartier with node\pages\loginpo.js:19:17)
at Context.<anonymous> (logintest.js:31:22)
Please help to resolve the issue or provide a way to use selenium pageobject in node js automation testing
The selenium-pageobject module is not part of this project, so I have no idea what the code is doing or why it would be failing. You'll need to file a bug against the project that publishes that module