I. What you need:
II. What you need to do:
- install python 2.7 in default directory (with adding to env PATH)
- install node.js in default(!) directory (with adding to env PATH)
- copy chromedriver to Python27/Scripts and add it to evn PATH
- run cmd as admin and:
pip install selenium npm install selenium-webdriver
example.js :
var webdriver = require('selenium-webdriver'),
By = require('selenium-webdriver').By,
until = require('selenium-webdriver').until,
driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
driver.get('http://www.google.com');
var element = driver.findElement(webdriver.By.name('q'));
element.sendKeys('Cheese!');
element.submit();
driver.getTitle().then(function(title) {
console.log('Page title is: ' + title);
});
driver.wait(function() {
return driver.getTitle().then(function(title) {
return title.toLowerCase().lastIndexOf('cheese!', 0) === 0;
});
}, 3000);
driver.getTitle().then(function(title) {
console.log('Page title is: ' + title);
});
driver.quit();
run the script:
node example.js
No comments:
Post a Comment