关于 nemojs-skill
nemojs-skill 是使用 PayPal 基于 Selenium 的 Node.js 自动化框架 Nemo.js 的参考技能,涵盖 Mocha 测试、元素定位、配置及 TestMu AI 云端执行。
主要功能
- 01基于 Mocha 的测试模式
- 02CSS 和 XPath 元素定位
- 03元素可见性等待与批量查找
- 04nemo.config.json 配置
- 05TestMu AI 云端执行指南
- 06安装与运行测试命令
适用场景
- 01使用 Mocha 和 Nemo.js 编写浏览器测试
- 02查找页面元素并等待其出现
- 03配置本地 WebDriver 端点
- 04设置 TestMu AI 云端执行
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ lambdatest/ agent-skills --skill nemojs-skill安装后在 Claude Code 中输入/nemojs-skill确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
reference/advanced-patterns.mdcloud-integration.mdplaybook.md详细介绍
Nemo.js 自动化技能
PayPal 基于 Selenium 的 Node.js 测试自动化框架。
有关在 TestMu AI 云端执行的信息,请参阅 reference/cloud-integration.md 和 shared/testmu-cloud-reference.md。
核心模式
基本测试(Mocha)
const Nemo = require('nemo');
const { expect } = require('chai');
describe('Login Flow', function() {
this.timeout(30000);
let nemo;
before(async () => {
nemo = await Nemo();
});
after(async () => {
await nemo.driver.quit();
});
it('should login with valid credentials', async () => {
await nemo.driver.get(nemo.data.baseUrl + '/login');
const email = await nemo.view._find('#email');
await email.sendKeys('[email protected]');
const password = await nemo.view._find('#password');
await password.sendKeys('password123');
await nemo.view._find('button[type="submit"]').click();
await nemo.view._waitVisible('.dashboard', 10000);
const url = await nemo.driver.getCurrentUrl();
expect(url).to.include('/dashboard');
});
it('should show error for invalid credentials', async () => {
await nemo.driver.get(nemo.data.baseUrl + '/login');
await nemo.view._find('#email').sendKeys('[email protected]');
await nemo.view._find('#password').sendKeys('wrong');
await nemo.view._find('button[type="submit"]').click();
await nemo.view._waitVisible('.error', 5000);
const error = await nemo.view._find('.error');
const text = await error.getText();
expect(text).to.include('Invalid');
});
});
视图定位器
await nemo.view._find('#css-id'); // CSS
await nemo.view._find('.class-name'); // CSS class
await nemo.view._find('[data-testid="login"]'); // Data attribute
await nemo.view._find('xpath://button[@type]'); // XPath prefix
await nemo.view._waitVisible(locator, timeout); // Wait + find
await nemo.view._finds('.items'); // Find multiple
配置(nemo.config.json)
{
"driver": {
"browser": "chrome",
"server": "http://localhost:4444/wd/hub"
},
"data": {
"baseUrl": "http://localhost:3000"
},
"view": ["locator"],
"plugins": {
"view": { "module": "nemo-view" }
}
}
在 TestMu AI 上云端执行
设置环境变量:LT_USERNAME、LT_ACCESS_KEY
{
"driver": {
"browser": "chrome",
"server": "https://hub.lambdatest.com/wd/hub",
"serverCaps": {
"username": "${LT_USERNAME}",
"accessKey": "${LT_ACCESS_KEY}"
},
"capabilities": {
"LT:Options": {
"user": "${LT_USERNAME}",
"accessKey": "${LT_ACCESS_KEY}",
"build": "Nemo Build",
"name": "Nemo Test",
"platformName": "Windows 11",
"video": true,
"console": true,
"network": true
}
}
}
}
设置:npm install nemo nemo-view --save-dev
运行:npx mocha test/*.js --timeout 30000
深入了解模式
有关高级模式、调试指南、CI/CD 集成和最佳实践,
请参阅 reference/playbook.md。
评论
支持 Markdown