npm i selenium-server nightwatch chromedriver -D |
const path = require('path'); module.exports = { // 测试文件入口 src_folders: ['tests'], // 输出报表路径 output_folder: 'reports', // selenium配置 selenium: { start_process: true, server_path: require('selenium-server').path, host: '127.0.0.1', // selenium log输出 log_path: 'reports', port: 9090, cli_args: { 'webdriver.chrome.driver': require('chromedriver').path, 'webdriver.gecko.driver': require('chromedriver').path } }, test_settings: { default: { launch_url: 'http://localhost', selenium_port: 9090, selenium_host: 'localhost', silent: true, screenshots: { enabled: false, path: '' } }, chrome: { desiredCapabilities: { browserName: 'chrome', javascriptEnabled: true, acceptSslCerts: true } } } }; |
module.exports = { 'Demo test Baidu' : function (browser) { browser .url('www.baidu.com') .waitForElementVisible('body', 1000) .setValue('input[name=wd]', 'NightWatch') .click('#su') .pause(1000) .assert.containsText('#container', 'NightWatch') .end(); } }; |
"scripts": { "test": "./node_modules/.bin/nightwatch --env" }; |
require('nightwatch/bin/runner.js'); |
npm install cypress --save-dev |
./node_modules/.bin/cypress open |
touch {your_project}/cypress/integration/simple_spec.js |
describe('My First Test', function() { it("Gets, types and asserts", function() { cy.visit('https://example.cypress.io') cy.contains('type').click() // Should be on a new URL which includes '/commands/actions' cy.url().should('include', '/commands/actions') // Get an input, type into it and verify that the value has been updated cy.get('.action-email') .type('fake@email.com') .should('have.value', 'fake@email.com') }) }) |
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) | Powered by Discuz! X3.2 |