var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until,
Key = webdriver.Key;
var chrome = require('selenium-webdriver/chrome');
var path = require('chromedriver').path;
var config = require('./config.js')();
var service = new chrome.ServiceBuilder(path).build();
chrome.setDefaultService(service);
var options = new chrome.Options()
.addArguments("start-maximized")
.addArguments("disable-infobars");
var driver = new webdriver.Builder()
.withCapabilities(webdriver.Capabilities.chrome())
.setChromeOptions(options)
.build();
driver.get( config.url.login ).then(function(){
driver.findElement(By.xpath( config.element.login.loginForm.xpath )).click();
driver.wait(until.elementLocated(By.name( config.element.login.username.name )), 5000);
driver.findElement(By.name( config.element.login.username.name )).sendKeys( config.data.login.username );
driver.findElement(By.name( config.element.login.password.name )).sendKeys( config.data.login.password );
driver.findElement(By.xpath( config.element.login.submit.xpath )).click();
});
driver.sleep(10 * 1000);
driver.quit();
module.exports = function() {
var config = {
url: {
login: "https://www.instagram.com/",
},
element: {
login: {
loginForm: { xpath: '//*[@id="react-root"]/section/main/article/div[2]/div[2]/p/a' },
username: { name: "username" },
password: { name: "password" },
submit: { xpath: '//*[@id="react-root"]/section/main/article/div[2]/div[1]/div/form/span/button' }
}
},
data: {
login: {
username: "USERNAME",
password: "PASSWORD"
},
},
}
return config;
}