Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Nightmare = require('nightmare')
- require('nightmare-iframe-manager')(Nightmare)
- var NXE = require('nightmare-xpath-event');
- Nightmare.action('touch', NXE.touch)
- Nightmare.action('clickByXpath', NXE.clickByXpath)
- const nightmare = Nightmare({
- show: true,
- webPreferences: {
- webSecurity:false
- }
- });
- var username = 'LevisFred@clouddev.makar-sankranti.in';
- var password = 'nopassword1305';
- var ORGANIZATION = 'Great Join';
- var ADDRESS_LINE_1 = 'Lalbahadur society, dhebar road, Rajkot ';
- var CITY = 'Surat';
- var POSTAL_CODE = '360002';
- var PHONE = '8511111595';
- nightmare.useragent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3163.300 Safari/537.36')
- nightmare.viewport(1366,768)
- /*--------------LOGIN-------------*/
- nightmare.goto('https://accounts.google.com/')
- .wait(4000)
- .type('#identifierId',username)
- .type('#identifierId','\u000d')//Enter Key
- .wait(5000)
- .type('input[type="password"]',password)
- .type('input[type="password"]','\u000d')//Enter Key
- .wait(5000)
- /*---ACCEPT---*/
- .exists('form#tos_form')
- .then(function(result){
- if(result)
- {
- console.log("+++"+result)
- nightmare.click('#accept')
- nightmare.wait(5000)
- }
- else
- {
- console.log("---"+result);
- }
- })
- .then(function(result){
- /*--------------Welcome Adwords-------------*/
- return nightmare
- .goto('https://adwords.google.com/cm/CampaignMgmt')
- .wait(30000)
- })
- .then(function(result){
- /*--------------Currency Selection-------------*/
- return nightmare
- .exists('.gwt-Anchor')
- .then(function(result){
- if(result)
- {
- console.log("+++"+result)
- nightmare.click('.gwt-Anchor')//Skip Button - Welcome Page
- nightmare.wait(17000)
- nightmare.exists('#gwt-debug-account-page-continue-button-content')
- .then(function(result){
- if(result)
- {
- return nightmare
- .click('#gwt-debug-account-page-continue-button-content')
- //Continue Button
- .wait(30000)
- }
- })
- }
- return nightmare.wait(500) //Just return
- })
- })
- .then(function(result){
- /*--------------Old Adwords Billing Page Load-------------*/
- return nightmare
- .goto('https://adwords.google.com/um/Billing/Home')
- .wait(28000)
- .exists('#gwt-debug-country-selection-page-continue-button-content')
- .then(function(result){
- if(result)
- {
- return nightmare
- .click('#gwt-debug-country-selection-page-continue-button-content')
- .wait(15000)
- }
- return nightmare.wait(15000)
- })
- })
- .then(function(result){
- /*--------------Fill Billing Information - FAKE Click-------------*/
- return nightmare
- .exists('#gwt-debug-billing-signup-page-payments-button-COMPLETE-content')
- .then(function(result){
- return nightmare
- .click('#gwt-debug-billing-signup-page-payments-button-COMPLETE-content')
- .wait(15000)
- })
- })
- .then(function(result){
- /*--------------Fill Billing Information - Personal Information-------------*/
- return nightmare
- .enterIFrame('#paymentsIframeContainerIframe')
- .then(function(result){
- return nightmare
- .wait(5000)
- .type('input[name="ORGANIZATION"]',ORGANIZATION)
- .type('input[name="ADDRESS_LINE_1"]',ADDRESS_LINE_1)
- .clickByXpath("//*[starts-with(text(),'State')]")
- .clickByXpath("//*[starts-with(text(),'Gujarat')]")
- .wait(2000)
- .type('input[name="LOCALITY"]',CITY)
- .type('input[name="POSTAL_CODE"]',POSTAL_CODE)
- .type('input[name="contact-phone"]',PHONE)
- })
- })
- /*--------------------------------*/
- /*---END PART---*/
- .then(console.log)
- .catch((error) => {
- console.error('ERRORS:', error);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement