Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
#lemoncase2
It's a tiny language for writing tests.
Statements end with a semicolon
No object, No array, LC2 is simple and just happens to be able to use.
RegExp is a string pattern for matching if use to ~~
.
Else it is a random string matched the pattern.
Macro will effect the case in the whole runtime.
// The case will try to run 10 times continuously.
#TIMES 10
// The case will wait 1000ms and start next time after this time finished.
#INTERVAL 1000
// The clock of case, excuting a instruction per 30ms.
#CLOCK 30
// Set the screen width 800px height 600px when the case run.
#SCREEN 800,600
// Auto scrolling the window when the trigger instruction excute in case.
#AUTOSCROLL
Simulate an action
Assert that the expression is true[ within overtime].
Wait a few time like a person.
Record the value of an expression.
Jump to a URL.
Refresh the page.
Define a test process.
You can not dispatch any event on a <iframe>
element by real devices, so actions can not use on them.
Any error will cause the Case to break and record to the log. Like no element existed, the rule of element not include the action.
Input a string to editable element like <input type="text" />
or <textarea>
.
// <input id="link" class="case" />
input 'div#link.case' by "hello world.";
Click a HTML element.
// <a href="...">Text</a>
click 'a';
// <a id="link" href="...'>Text</a>
click 'a#link';
Double click a HTML element.
// <div id="link" class="case">Text</div>
dblclick 'div#link.case';
Right click a HTML element.
// <div id="link" class="case">Text</div>
rclick 'div#link.case';
Select a <option> in <select> by value|index. (just use to <select>)
// <select>
// <option value="a"></option> // index:0
// <option value="b"></option> // index:1 <-- want to select
// <option value="c"></option> // index:2
// </select>
select "select" by 1;
// OR
select "select" by "b";
Mouse move in. Like click
.
Mouse move out. Like click
.
Scroll a page or element.
<
.
<iframe>
<!-- From top frame -->
<iframe id="top">
#document
<html>
<body>
<iframe id="project">
#document
<html>
<body>
<a href="./">link</a> <!-- select it. -->
<b>link</b>
</body>
</html>
</iframe>
</body>
</html>
</iframe>
iframe < iframe < a
* < * < a
#top < #project < a
* < #project < a:contain(link)
<# [selector:string] />
//Get length of the element set. It is a number (>0).
// <div id="link" class="case">Text</div>
log <# 'div'/>; // Output 1
log <# '#link'/>; // Output 1
log <# '#no'/>; // Output 0
<@ [selector:string] />
// Get the innerHTML of the 1st element in query set.
// The result is a string if element is existed.
// It is `false` if element is not existed.
// <div id="link" class="case">Text</div>
log <@ 'div'/>; // Output Text
log <@ '#link'/>; // Output Text
log <@ '#no'/>; // Output false
<! [selector:string] />
// Check the element is visibale or not.
// The result is `true` if element is existed && width > 0 && height > 0 else `false`.
// <div id="link" class="case">Text</div>
// <div id="link2" style="display:none">Text</div>
log <@ 'a'/>; // Output false
log <@ 'div'/>; // Output true
log <@ '#link2'/>; // Output false
[[property:string]:[selector:string]]
- beta
Get the value of property of the element query by selector.
{[cssAttr:string]:[selector:string]}
- beta
Get the value of css attribute of the element query by selector.
[exp_A:string] ~~ [exp_B:string|RegExp]
[exp_A:string] !~ [exp_B:string|RegExp]
return
keyword in LC2. A process
has no paramater.process main
is the program entry. It must be defined.Here are some examples for inspiration.
process main {
log 'hello world';
}
Test case for function point just need run 1 timee.
#TIMES 1
process main {
jumpto '[URL]';
wait 2000;
...
[statement]
...
}
A register page.
#TIMES 1
#INTERVAL 3000
process main {
jumpto '/#/register';
wait 2000;
// There are 5 text boxes.
assert <#'#userInfoFrom input'/> === 5;
// There is a captcha svg.
assert <!"img.pull-right"/>;
// There is a login button.
assert <!"#userInfoFrom > button.btn"/>;
// There is a home button.
assert <@"#global-back-button"/> ~~ 'glyphicon-home';
userNameRule = "#name-rule > div";
// Input username length < 6
input "#account-name" by '12345';
assert <@userNameRule/> ~~ '不少于6个字符';
// Input username length > 16
input "#account-name" by /\w{17}/;
assert <@userNameRule/> ~~ '不超过16个字符';
// Username is blank
input "#account-name" by '';
assert <@userNameRule/> ~~ '用户名不为空';
// Username is repeat.
input "#account-name" by 'active';
click "#account-email";
assert <!"#name-repeat"/> && <@"#name-repeat"/> ~~ '用户名重复' in 2000;
// Blank email.
emailRule = "#email-rule > div";
input "#account-email" by '';
assert <@emailRule/> ~~ '邮箱不为空';
// Error email
input "#account-email" by 'fdsf';
assert <@emailRule/> ~~ '请输入正确格式的邮箱';
// Repeat email
input "#account-email" by 'lichao@or-change.cn';
click "#account-password";
assert <!"#emial-repeat"/> && <@"#emial-repeat"/> ~~ '邮箱重复' in 2000;
// Input password length < 8
input "#account-password" by /\w{1,7}/;
assert <@"#password-rule > div"/> ~~ '不少于8个字符';
// Input password length >20
input "#account-password" by /\w{20,}/;
assert <@"#password-rule > div"/> ~~ '不超过20个字符';
// Blank password
input "#account-password" by '';
assert <@"#password-rule > div"/> ~~ '密码不为空';
// Error char.
input "#account-password" by '测试测试测试测试';
assert <@"#password-rule > div"/> ~~ '您输入了非法字符';
// Password !== Confirm
password = /\w{10}/;
input "#account-password" by password;
input "#account-password-confirm" by password + 'a';
assert <@"#confirm-rule > div"/> ~~ '两次输入不一致';
}
FAQs
browser automation library
The npm package lc2 receives a total of 40 weekly downloads. As such, lc2 popularity was classified as not popular.
We found that lc2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.