動作確認済のプログラムが長いので関数を用いて記述したところ、構文エラーにはならないものの関数表記した部分で止まってしまいます。何が原因でしょうか?
js
1var Nightmare = require('nightmare'); 2var nightmare = Nightmare({ show: true }); 3var mail = '●'; 4var password = '●'; 5var securityCode = '●'; // !!! DANGER !! 6var itemUrl = 'https://www.yodobashi.com/product/100000001002085539/index.html'; 7function ending() 8{ 9nightmare 10.wait('.btnOrange.js_c_payment.js_c_filterBtn') 11.wait(3000) 12.click('.btnOrange.js_c_payment.js_c_filterBtn') 13.wait('.js_c_point_select.js_c_usePoint') 14.click('.js_c_point_select.js_c_usePoint') 15.type('input#goldPointForUse', '●') 16.click('.btnRed.js_c_next') 17.wait('#creditCard\.securityCode') 18.insert('#creditCard\.securityCode', securityCode) 19.wait(3000) 20.click('.btnRed.js_c_order.js_c_filterBtn') 21.wait('.orderFinishItemInfo') 22.end() 23.then((result) => {console.log('done');}) 24.catch((error) => {console.error('Search failed:', error);}) 25} 26 27function credit() 28{ 29nightmare 30.wait('input#cardNumber') 31.type('input#cardNumber','●') 32.select('select#cardExpirationMonth','●') 33.select('select#cardExpirationYear','●') 34.click('#js_i_next.btnRed') 35} 36 37// 前提条件:ログインしていない 38nightmare 39 .goto(itemUrl) 40 .wait('#js_buyBox') 41 // 商品をカートに追加 42 .select('select#qtySel','●' ) 43 .click('.yBtnText') 44 // 購入手続きへ進む 45 .wait('.cartinBox') 46 .goto('https://order.yodobashi.com/yc/shoppingcart/index.html?next=true') 47 .click('#sc_i_buy') 48 // ログイン 49 .wait('#js_i_form') 50 .type('input#memberId', mail) 51 .type('input#password', password) 52 .click('#js_i_login0') 53 // ログインするとカートへリダイレクトされるので表示されるまで待つ 54 .wait('.cartItemBlock') 55 .click('#sc_i_buy') 56 //メインフローの分岐 57 .wait('#js_i_form') 58 .exists('input#cardNumber') 59 .then(function (result) 60{ 61 if (result) { 62 return 63 credit() 64 //住所変更~最後まで続く,以下略.ココで止まる 65 ... 66 //住所変更~最後まで終わり 67 } else { 68 return 69 //住所変更~最後まで 70 ... 71 //住所変更~最後まで終わり 72 73}); 74
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。