title | tags | parameters | reference | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
タイムズカーシェアで直前に利用したステーションの車を土日一番予約できる先の日付で予約します |
|
|
Last active
April 4, 2021 01:32
-
-
Save freddiefujiwara/f5be9a6b62f123b2c2734ecdf94bd8a4 to your computer and use it in GitHub Desktop.
dogbot-times-holiday-booking.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { | |
I | |
} = inject(); | |
module.exports = { | |
async run() { | |
// 1.タイムズカーシェアのトップページのログインボタンをクリック | |
I.amOnPage('https://share.timescar.jp/sp/'); | |
I.click('ログイン'); | |
I.wait(2); | |
// 2. ログインフォームからログイン (環境変数から TIMES_CARDNO1,TIMES_CARDNO2, TIMES_PASSWORD を取得しています) | |
I.fillField('tpLoginForm:cardNo1', process.env.TIMES_CARDNO1); | |
I.fillField('tpLoginForm:cardNo2', process.env.TIMES_CARDNO2); | |
I.fillField('tpLoginForm:tpPassword', process.env.TIMES_PASSWORD); | |
I.click('#tpLogin'); | |
// たまに、モーダルのポップアップが出てくるので、"了解"を押してモーダルをクローズします | |
let entry = true; | |
while (entry) { | |
const kakunin = locate('span.ui-btn-text').withText('確認'); | |
const k = await I.grabNumberOfVisibleElements(kakunin); | |
if (k > 0) I.click(kakunin); | |
const ryokai = locate('span').withText('了解'); | |
const r = await I.grabNumberOfVisibleElements(ryokai); | |
if (r > 0) I.click(ryokai); | |
const doui = locate('span').withText('同意する'); | |
const d = await I.grabNumberOfVisibleElements(doui); | |
if (d > 0) I.click(doui); | |
if (k === 0 & r === 0 & d === 0) entry = false; | |
I.wait(3); | |
} | |
// 3. 簡単予約ボタンをクリック | |
I.click('簡単予約'); | |
I.click('予約'); | |
// 4. 予約できる一番先の日付を選択して検索 | |
const targetDates = await I.grabTextFromAll('#dateSpace > option'); | |
I.selectOption('#dateSpace', targetDates.pop()); | |
I.selectOption('#hourSpace', process.env.TIMES_STARTHH); | |
I.click('検索'); | |
// 5. 利用開始時間、返却予定時間を取得し予約 (環境変数から利用開始時間 TIMES_STARTHH 、返却予定時間 TIMES_ENDHH を取得しています) | |
I.click('予約入力画面へ'); | |
I.selectOption('#hourEnd', process.env.TIMES_ENDHH); | |
I.click('入力内容確認'); | |
I.wait(2); | |
I.click('予約確定'); | |
const ryokai = locate('#licenseAgreeButton').withText('了解'); | |
const r = await I.grabNumberOfVisibleElements(ryokai); | |
if (r > 0) I.click(ryokai); | |
I.wait(2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment