Hi everyone,
all tutorials i have seen are done like this and they work:
file name: *test.js*
driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
driver.get( 'go.to.some.page.com');
var searchBox = driver.findElement(webdriver.By.name('q'));
searchBox.sendKeys('simple programmer');
searchBox.getAttribute('value').then(function(value) {
assert.equal(value, 'simple programmer');
});
Now after i have done this and now wanna move on with nicer and reusable test
code I am facing with test helpers . I made following helper file:
file name: *helper.js*
var webdriver = require('selenium-webdriver');
var By = require('selenium-webdriver').By;
exports.logIn = function(user,pass) {
var loginForm = webdriver.WebElement.findElement(By.id('loginForm'));
if(loginForm) {
var login = webdriver.WebElement.findElement(By.name('user'));
var pass = webdriver.WebElement.findElement(By.name('pass'));
login.sendKeys(user);
login.sendKeys(pass);
webdriver.WebElement.findElement(By.id('login-button')).click()
}
};
and *test.js* looks like this:
var assert = require('assert'),
test = require('selenium-webdriver/testing'),
webdriver = require('selenium-webdriver'),
login = require('./helper').logIn();
test.describe('Google Search', function() {
this.timeout(15000);
var driver;
test.after(function() {
driver.close();
driver.quit();
});
test.it('Valdiate "Calls and messages"', function() {
driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
driver.get( 'to.login.page.com');
driver.logina('blab','bla');
var searchBox = driver.findElement(webdriver.By.name('q'));
searchBox.sendKeys('simple programmer');
searchBox.getAttribute('value').then(function(value) {
assert.equal(value, 'simplekk programmer');
});
});
});
and when i run this test i get following:
var loginForm = webdriver.WebElement.findElement(By.id('loginForm'));
^
TypeError: webdriver.WebElement.findElement is not a function
can someone please explain me how to do it correctly :)
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/7efcac04-fd01-423f-ad2f-bcf3dc7fe25a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.