Advertisement
Guest User

Untitled

a guest
Jan 11th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.98 KB | None | 0 0
  1. var Nightmare = require('nightmare')
  2. require('nightmare-iframe-manager')(Nightmare)
  3.  
  4. var NXE = require('nightmare-xpath-event');
  5. Nightmare.action('touch', NXE.touch)
  6. Nightmare.action('clickByXpath', NXE.clickByXpath)
  7.  
  8. const nightmare = Nightmare({
  9. show: true,
  10. webPreferences: {
  11. webSecurity:false
  12. }
  13. });
  14.  
  15. var username = 'LevisFred@clouddev.makar-sankranti.in';
  16. var password = 'nopassword1305';
  17. var ORGANIZATION = 'Great Join';
  18. var ADDRESS_LINE_1 = 'Lalbahadur society, dhebar road, Rajkot ';
  19. var CITY = 'Surat';
  20. var POSTAL_CODE = '360002';
  21. var PHONE = '8511111595';
  22.  
  23. 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')
  24. nightmare.viewport(1366,768)
  25.  
  26. /*--------------LOGIN-------------*/
  27. nightmare.goto('https://accounts.google.com/')
  28. .wait(4000)
  29. .type('#identifierId',username)
  30. .type('#identifierId','\u000d')//Enter Key
  31. .wait(5000)
  32. .type('input[type="password"]',password)
  33. .type('input[type="password"]','\u000d')//Enter Key
  34. .wait(5000)
  35. /*---ACCEPT---*/
  36. .exists('form#tos_form')
  37. .then(function(result){
  38. if(result)
  39. {
  40. console.log("+++"+result)
  41. nightmare.click('#accept')
  42. nightmare.wait(5000)
  43. }
  44. else
  45. {
  46. console.log("---"+result);
  47. }
  48. })
  49. .then(function(result){
  50. /*--------------Welcome Adwords-------------*/
  51. return nightmare
  52. .goto('https://adwords.google.com/cm/CampaignMgmt')
  53. .wait(30000)
  54. })
  55. .then(function(result){
  56. /*--------------Currency Selection-------------*/
  57. return nightmare
  58. .exists('.gwt-Anchor')
  59. .then(function(result){
  60. if(result)
  61. {
  62. console.log("+++"+result)
  63. nightmare.click('.gwt-Anchor')//Skip Button - Welcome Page
  64. nightmare.wait(17000)
  65. nightmare.exists('#gwt-debug-account-page-continue-button-content')
  66. .then(function(result){
  67. if(result)
  68. {
  69. return nightmare
  70. .click('#gwt-debug-account-page-continue-button-content')
  71. //Continue Button
  72. .wait(30000)
  73. }
  74. })
  75. }
  76. return nightmare.wait(500) //Just return
  77. })
  78. })
  79. .then(function(result){
  80. /*--------------Old Adwords Billing Page Load-------------*/
  81. return nightmare
  82. .goto('https://adwords.google.com/um/Billing/Home')
  83. .wait(28000)
  84. .exists('#gwt-debug-country-selection-page-continue-button-content')
  85. .then(function(result){
  86. if(result)
  87. {
  88. return nightmare
  89. .click('#gwt-debug-country-selection-page-continue-button-content')
  90. .wait(15000)
  91. }
  92. return nightmare.wait(15000)
  93. })
  94. })
  95. .then(function(result){
  96. /*--------------Fill Billing Information - FAKE Click-------------*/
  97. return nightmare
  98. .exists('#gwt-debug-billing-signup-page-payments-button-COMPLETE-content')
  99. .then(function(result){
  100. return nightmare
  101. .click('#gwt-debug-billing-signup-page-payments-button-COMPLETE-content')
  102. .wait(15000)
  103. })
  104. })
  105. .then(function(result){
  106. /*--------------Fill Billing Information - Personal Information-------------*/
  107. return nightmare
  108. .enterIFrame('#paymentsIframeContainerIframe')
  109. .then(function(result){
  110. return nightmare
  111. .wait(5000)
  112. .type('input[name="ORGANIZATION"]',ORGANIZATION)
  113. .type('input[name="ADDRESS_LINE_1"]',ADDRESS_LINE_1)
  114. .clickByXpath("//*[starts-with(text(),'State')]")
  115. .clickByXpath("//*[starts-with(text(),'Gujarat')]")
  116. .wait(2000)
  117. .type('input[name="LOCALITY"]',CITY)
  118. .type('input[name="POSTAL_CODE"]',POSTAL_CODE)
  119. .type('input[name="contact-phone"]',PHONE)
  120.  
  121. })
  122. })
  123.  
  124.  
  125. /*--------------------------------*/
  126.  
  127.  
  128. /*---END PART---*/
  129. .then(console.log)
  130. .catch((error) => {
  131. console.error('ERRORS:', error);
  132. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement