Showing
1 changed file
with
78 additions
and
42 deletions
| ... | @@ -49,87 +49,123 @@ async function runrun() { | ... | @@ -49,87 +49,123 @@ async function runrun() { |
| 49 | ); | 49 | ); |
| 50 | multipleClick(page); | 50 | multipleClick(page); |
| 51 | 51 | ||
| 52 | - // await page.type("Selector 입력", code); | 52 | + await page.type("#crtfNo", code); |
| 53 | - // await page.click("확인버튼 selector"); | 53 | + await page.click("#crtfBtn"); |
| 54 | + await page.click("body > div:nth-child(23) > div.ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix > div > button.di_btn_conf.ui-button.ui-widget.ui-state-default.ui-corner-all.ui-button-text-only"); | ||
| 55 | + await page.goto("https://portal.khu.ac.kr/haksa/clss/clss/elctCrtf/index.do"); | ||
| 56 | + | ||
| 54 | result = await checkStatus(page); | 57 | result = await checkStatus(page); |
| 55 | console.log(result); | 58 | console.log(result); |
| 56 | - | 59 | + browser.close(); |
| 57 | 60 | ||
| 58 | } catch (err) { | 61 | } catch (err) { |
| 59 | console.log(err); | 62 | console.log(err); |
| 60 | } | 63 | } |
| 61 | } | 64 | } |
| 62 | 65 | ||
| 63 | - | ||
| 64 | - | ||
| 65 | async function multipleClick(page) { | 66 | async function multipleClick(page) { |
| 66 | let data = []; | 67 | let data = []; |
| 67 | - | ||
| 68 | let selector = "#baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody"; | 68 | let selector = "#baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody"; |
| 69 | const number = await page.$$eval(selector, (data) => data.length); | 69 | const number = await page.$$eval(selector, (data) => data.length); |
| 70 | - page.click("#baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody > tr.first"); | 70 | + try{ |
| 71 | - page.click("#baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody > tr.last"); | 71 | + for (let index = 2; index < number; index++) { |
| 72 | - for (let index = 2; index < number; index++) { | 72 | + page.click(`#baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody > tr:nth-child("+ ${index} +") > td.first.input_td > a`) |
| 73 | - page.click(`#baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody > tr:nth-child("+ ${index} +")`) | 73 | + } |
| 74 | + page.click("#baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody > tr.first > td.first.input_td > a"); | ||
| 75 | + page.click("#baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody > tr.last > td.first.input_td > a"); | ||
| 76 | + } | ||
| 77 | + catch(err){ | ||
| 78 | + console.log("error!"); | ||
| 74 | } | 79 | } |
| 80 | + | ||
| 75 | } | 81 | } |
| 76 | 82 | ||
| 77 | async function checkStatus(page) { | 83 | async function checkStatus(page) { |
| 78 | - let data = []; | ||
| 79 | let selector = "#baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody"; | 84 | let selector = "#baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody"; |
| 80 | const number = await page.$$eval(selector, (data) => data.length); | 85 | const number = await page.$$eval(selector, (data) => data.length); |
| 81 | 86 | ||
| 82 | - data.push(await except(page)); | ||
| 83 | for (let index = 2; index < number; index++) { | 87 | for (let index = 2; index < number; index++) { |
| 84 | - data.push(await getOne(page, index)); | 88 | + if (await getOne(page, index) == "인증완료"){ |
| 89 | + return "success"; | ||
| 90 | + } | ||
| 91 | + else{ | ||
| 92 | + return "failed"; | ||
| 93 | + } | ||
| 85 | } | 94 | } |
| 86 | - // const promise3 = Promise.resolve(data); | 95 | + |
| 87 | - // promise3.then(value => { | 96 | + //exception(first context) |
| 88 | - // for (let index = 0; index < value.length; index++) { | ||
| 89 | - // if (value[index]=="출석완료") { | ||
| 90 | - // return "success"; | ||
| 91 | - // } | ||
| 92 | - // else{ | ||
| 93 | - // return "fail"; | ||
| 94 | - // } | ||
| 95 | - // } | ||
| 96 | - // }) | ||
| 97 | - return data; | ||
| 98 | - } | ||
| 99 | - async function except(page) { | ||
| 100 | - let data = {}; | ||
| 101 | let temp = await page.$( | 97 | let temp = await page.$( |
| 102 | - "#baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody > tr.first > td.td_btn" | 98 | + "#baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody > tr.first > td.first" |
| 103 | ); | 99 | ); |
| 104 | - data.name = await page.evaluate((data) => { | 100 | + checking = await page.evaluate((data) => { |
| 105 | - data.push(data.textContent); | 101 | + if (data.textContent == "인증완료"){ |
| 102 | + return "success"; | ||
| 103 | + } | ||
| 104 | + else{ | ||
| 105 | + return "failed"; | ||
| 106 | + } | ||
| 106 | }, temp); | 107 | }, temp); |
| 108 | + | ||
| 107 | 109 | ||
| 110 | + //exception(last context) | ||
| 108 | let templast = await page.$( | 111 | let templast = await page.$( |
| 109 | - "#baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody > tr.last > td.td_btn" | 112 | + "#baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody > tr.last > td.first" |
| 110 | ); | 113 | ); |
| 111 | - data.name = await page.evaluate((data) => { | 114 | + checking = await page.evaluate((data) => { |
| 112 | - data.push(data.textContent); | 115 | + if (data.textContent == "인증완료"){ |
| 116 | + return "success"; | ||
| 117 | + } | ||
| 118 | + else{ | ||
| 119 | + return "failed"; | ||
| 120 | + } | ||
| 113 | }, templast); | 121 | }, templast); |
| 114 | - return Promise.resolve(data); | 122 | + |
| 115 | -} | 123 | + } |
| 116 | 124 | ||
| 117 | 125 | ||
| 126 | + | ||
| 118 | async function getOne(page, index) { | 127 | async function getOne(page, index) { |
| 119 | - let data = {}; | ||
| 120 | let temp = await page.$( | 128 | let temp = await page.$( |
| 121 | - "#baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody > tr:nth-child("+index+ ") > td.td_btn" | 129 | + "#baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody > tr:nth-child("+index+ ") > td.first" |
| 122 | ); | 130 | ); |
| 123 | - data.name = await page.evaluate((data) => { | 131 | + checking = await page.evaluate((data) => { |
| 124 | return data.textContent; | 132 | return data.textContent; |
| 125 | }, temp); | 133 | }, temp); |
| 126 | 134 | ||
| 127 | - return Promise.resolve(data); | 135 | + return Promise.resolve(checking); |
| 128 | } | 136 | } |
| 129 | 137 | ||
| 130 | 138 | ||
| 131 | async function test() { | 139 | async function test() { |
| 132 | await runrun(); | 140 | await runrun(); |
| 133 | - await attendanceCheck("오픈소스SW개발 00분반", 1234); | 141 | + await attendanceCheck("오픈소스SW개발", 2022); |
| 134 | } | 142 | } |
| 135 | -test(); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 143 | +test(); | ||
| 144 | + | ||
| 145 | + | ||
| 146 | + | ||
| 147 | + | ||
| 148 | + | ||
| 149 | +// //인증하기 | ||
| 150 | +// #baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody > tr.first > td.first.input_td > a | ||
| 151 | +// #baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody > tr.first > td.first.input_td > a > span > b | ||
| 152 | +// #baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody > tr.last > td.first | ||
| 153 | +// //입력하기 | ||
| 154 | +// #crtfNo | ||
| 155 | + | ||
| 156 | +// //인증 버튼 누르기 | ||
| 157 | +// #crtfBtn | ||
| 158 | + | ||
| 159 | +// //확인 | ||
| 160 | +// body > div:nth-child(23) > div.ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix > div > button.di_btn_conf.ui-button.ui-widget.ui-state-default.ui-corner-all.ui-button-text-only | ||
| 161 | + | ||
| 162 | +// //닫기 | ||
| 163 | +// body > div:nth-child(23) > div.ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix > div > button.di_btn_conf.ui-button.ui-widget.ui-state-default.ui-corner-all.ui-button-text-only | ||
| 164 | + | ||
| 165 | + | ||
| 166 | +// //인증완료 | ||
| 167 | +// #baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody > tr.first > td.first | ||
| 168 | +// #baseForm > div:nth-child(3) > div.table_wrap.pc_view > table > tbody > tr.last > td.first | ||
| 169 | +// .name 사용 | ||
| 170 | + | ||
| 171 | +// page | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment