Toggle navigation
Toggle navigation
This project
Loading...
Sign in
신원형
/
study-or-enjoy
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
신원형
2022-05-26 00:13:06 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e3c8c669599047f97bf1585909063121dd787b5c
e3c8c669
1 parent
fc54f3e7
improved test code
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
24 deletions
.eslintrc.json
khcanvas.js
package-lock.json
package.json
test/khcanvas_test.js
.eslintrc.json
0 → 100644
View file @
e3c8c66
{
"env"
:
{
"browser"
:
true
,
"es2021"
:
true
},
"extends"
:
"eslint:recommended"
,
"parserOptions"
:
{
"ecmaVersion"
:
"latest"
,
"sourceType"
:
"module"
},
"rules"
:
{
}
}
khcanvas.js
View file @
e3c8c66
...
...
@@ -40,10 +40,10 @@ ex)
*/
export
async
function
get_schedule
(
id
,
pw
,
target_date
)
{
return
using_selenium
(
(
driver
)
=>
{
return
login
(
driver
,
id
,
pw
)
.
then
(()
=>
{
return
load
(
driver
,
target_date
)
return
await
using_selenium
(
async
(
driver
)
=>
{
return
await
login
(
driver
,
id
,
pw
)
.
then
(
async
()
=>
{
return
await
load
(
driver
,
target_date
)
.
then
((
data
)
=>
{
//logout(driver)
console
.
log
(
data
)
...
...
@@ -99,7 +99,7 @@ export async function load(driver, until) {
export
async
function
logout
(
driver
)
{
await
driver
.
get
(
"https://khcanvas.khu.ac.kr/"
)
const
logoutPanel
=
await
driver
.
findElement
(
selenium
.
By
.
xpath
(
'html/body/div[2]/header[2]/div[1]/ul/li[1]/button/div[1]'
)).
click
();
await
driver
.
findElement
(
selenium
.
By
.
xpath
(
'html/body/div[2]/header[2]/div[1]/ul/li[1]/button/div[1]'
)).
click
();
await
sleep
(
1000
)
const
logout
=
await
driver
.
findElement
(
selenium
.
By
.
xpath
(
'html/body/div[3]/span/span/div/div/div/div/div/span/form/button'
));
logout
.
click
()
...
...
package-lock.json
View file @
e3c8c66
This diff is collapsed. Click to expand it.
package.json
View file @
e3c8c66
...
...
@@ -14,12 +14,12 @@
"license"
:
""
,
"dependencies"
:
{
"@types/selenium-webdriver"
:
"^4.1.0"
,
"eslint"
:
"^8.16.0"
,
"mocha"
:
"^10.0.0"
,
"selenium-webdriver"
:
"^4.1.2"
},
"type"
:
"module"
,
"devDependencies"
:
{
"@types/node"
:
"^17.0.35"
"@types/node"
:
"^17.0.35"
,
"eslint"
:
"^8.16.0"
}
}
...
...
test/khcanvas_test.js
View file @
e3c8c66
...
...
@@ -2,14 +2,17 @@
//https://github.com/gatoona/AWS-Selenium
import
*
as
canvas
from
'../khcanvas.js'
import
*
as
rd
from
'readline'
import
{
assert
}
from
'console'
;
import
*
as
mocha
from
'mocha'
import
process
from
'node:process'
;
import
util
from
'util'
import
{
rejects
}
from
'assert'
;
describe
(
'khcanvas'
,
()
=>
{
it
(
'opening selenium
'
,
()
=>
{
//this.timeout(1000);
canvas
.
using_selenium
(
async
(
driver
)
=>
{
mocha
.
describe
(
'khcanvas
'
,
()
=>
{
mocha
.
it
(
'opening selenium'
,
async
()
=>
{
await
canvas
.
using_selenium
(
async
(
driver
)
=>
{
await
driver
.
get
(
"http://khuhub.khu.ac.kr"
);
await
driver
.
getTitle
().
then
(
function
(
title
)
{
await
driver
.
getTitle
().
then
(
(
title
)
=>
{
console
.
log
(
title
);
});
});
...
...
@@ -17,24 +20,23 @@ describe('khcanvas', () => {
});
describe
(
'khcanvas'
,
()
=>
{
it
(
'get schedule'
,
async
()
=>
{
mocha
.
describe
(
'khcanvas'
,
()
=>
{
mocha
.
it
(
'get schedule'
,
async
()
=>
{
const
rl
=
rd
.
createInterface
({
input
:
process
.
stdin
,
output
:
process
.
stdout
})
rl
.
question
(
'a'
,
async
(
a
)
=>
{
rl
.
question
(
'b'
,
async
(
b
)
=>
{
await
canvas
.
get_schedule
(
a
,
b
,
new
Date
())
.
then
(
it
=>
{
console
.
log
(
it
)
})
const
question
=
util
.
promisify
(
rl
.
question
).
bind
(
rl
);
const
a
=
await
question
(
'a'
);
const
b
=
await
question
(
'b'
);
return
await
canvas
.
get_schedule
(
a
,
b
,
new
Date
())
.
then
(
it
=>
console
.
log
(
it
))
.
catch
(
it
=>
{
console
.
log
(
it
)
throw
new
Error
();
})
})
rejects
(
it
)
})
})
});
\ No newline at end of file
...
...
Please
register
or
login
to post a comment