jeudi 27 septembre 2018

selenium unit testing is not working with simple usecase

I am a devloper who is trying to do some automation testing

I have choosen selenium-webdriver with mocha to achive it

I got sample as shown below

var webdriver = require('selenium-webdriver') // Added line
var By = require('selenium-webdriver').By,
    until = require('selenium-webdriver').until,
    chrome = require('selenium-webdriver/chrome'),
    test = require('selenium-webdriver/testing');

test.describe('Google Search', function() {
    var driver;

    test.before(function() {
        driver = new webdriver.Builder().forBrowser('chrome').build() // Changed line
    });

    test.after(function() {
        driver.quit();
    });

    test.it('should append query to title', function() {
        driver.get('http://www.google.com/ncr');
        driver.findElement(By.name('q')).sendKeys('webdriver');
        driver.findElement(By.name('btnG')).click();
        driver.wait(until.titleIs('webdriver - Google Search'), 1000);
    });
});

i have installed chrominum node and mocha

but when i do mocha filename

/home/dhanalakshmi/Desktop/seleniumm testing/test-project/spec.js:7 test.describe('Google Search', function() { ^

TypeError: test.describe is not a function at Object. (/home/dhanalakshmi/Desktop/seleniumm testing/test-project/spec.js:7:6) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10)

i am getting the error as shown please say how to run the test case

Aucun commentaire:

Enregistrer un commentaire