Created
February 14, 2019 01:09
-
-
Save kysnrm/792188fd0449a95afcb4d9dfd1d0e99f to your computer and use it in GitHub Desktop.
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 puppeteer = require('puppeteer'); | |
(async () => { | |
const browser = await puppeteer.launch({ | |
headless: false, | |
slowMo: 100, | |
args: [ | |
'--window-size=1440,900', | |
] | |
}); | |
const page = await browser.newPage(); | |
await page.setViewport({ | |
width: 1440, | |
height: 765 | |
}); | |
await page.goto('https://accounts.shopify.com/store-login'); | |
await page.waitForSelector('#shop_domain'); | |
await page.type('#shop_domain', 'ecbooster.myshopify.com'); | |
page.click('button[name="commit"]'); | |
await page.waitForSelector('#account_email'); | |
await page.type('#account_email', '[email protected]'); | |
page.click('button[name="commit"]'); | |
await page.waitForSelector('#account_password'); | |
await page.waitFor(10000); | |
await page.waitForSelector('a[href="/admin/apps"]'); | |
page.click('a[href="/admin/apps"]'); | |
await page.waitForSelector('a[href="https://ecbooster.myshopify.com/admin/apps/canvath-1"]'); | |
page.click('a[href="https://ecbooster.myshopify.com/admin/apps/canvath-1"]'); | |
await page.waitFor(10000); | |
let frame = page.frames().find(frame => frame.name() === 'app-iframe'); | |
// await page.evaluate(() => alert(frame)); | |
frame.click('#global-header > div > nav > ul > li.brsh-header__list-item.if-mobile-hide > a'); | |
await frame.waitForSelector('#product_lineup > div > section > div > div:nth-child(15) > div:nth-child(2) > div.action > a'); | |
frame.click('#product_lineup > div > section > div > div:nth-child(15) > div:nth-child(2) > div.action > a'); | |
await frame.waitForSelector('input[type="file"]'); | |
const uploader = await frame.$('input[type="file"]'); | |
await uploader.uploadFile('kairokobo-tshirt-resistance_0.47.png'); | |
await page.waitFor(10000); | |
await frame.waitForSelector('#material_design_attributes_title'); | |
// await frame.type('#material_design_attributes_title','抵抗Tシャツ'); | |
await frame.$eval('#material_design_attributes_title', e => e.value = '抵抗Tシャツ'); | |
frame.click('#material_save'); | |
const shirtSize = ['s', 'm', 'm', 'l', 'l', 'xl', 'xl']; | |
for (let i = 2; i < shirtSize.length; i++) { | |
await frame.waitForSelector('.design_link'); | |
frame.click('.design_link'); | |
await frame.waitForSelector('#image-originals > div > div.row.materials > div.col-md-9 > a'); | |
frame.click('#image-originals > div > div.row.materials > div.col-md-9 > a'); | |
await frame.waitFor('#size_code', { | |
timeout: 60000 | |
}); | |
await frame.select('#size_code', shirtSize[i]); | |
if (i % 2 === 0) { | |
await frame.select('#color_code', 'black'); | |
} | |
frame.click('#material_save'); | |
} | |
await browser.close(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment