mcpField
N
nemojs-skill

nemojs-skill

github.com/lambdatest测试与质量384203 次安装2 周前更新
代码仓库

关于 nemojs-skill

nemojs-skill 是使用 PayPal 基于 Selenium 的 Node.js 自动化框架 Nemo.js 的参考技能,涵盖 Mocha 测试、元素定位、配置及 TestMu AI 云端执行。

主要功能

  1. 01基于 Mocha 的测试模式
  2. 02CSS 和 XPath 元素定位
  3. 03元素可见性等待与批量查找
  4. 04nemo.config.json 配置
  5. 05TestMu AI 云端执行指南
  6. 06安装与运行测试命令

适用场景

  1. 01使用 Mocha 和 Nemo.js 编写浏览器测试
  2. 02查找页面元素并等待其出现
  3. 03配置本地 WebDriver 端点
  4. 04设置 TestMu AI 云端执行

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/lambdatest/agent-skills --skill nemojs-skill

安装后在 Claude Code 中输入/nemojs-skill确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

reference/
advanced-patterns.md
cloud-integration.md
playbook.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