const dgram = require("dgram");
const client = dgram.createSocket('udp4');
client.send('客户端发起的信息!', 41234, 'localhost', (err) => {
client.close();
});
const http = require('http');
const fs = require('fs');
http.createServer(function (req, res) {
(async () => {
const file = fs.readFileSync('log.txt');
console.log(file.toString())
})();
res.writeHead(200, { 'Content-Type': 'text/html' });
res.write('Node.js says hello!');
res.end();
}).listen(8080);
import { test, expect } from '@playwright/test';
test('test', async ({ page, context }) => {
//在创建/导航页面之前开始跟踪
const obj = {
screenshots: true,
snapshots: true,
sources: true
}
await context.tracing.start(obj)
await page.goto('http://good1230.com/');
//遍历菜单
const count = await page.locator('ul.width-135 > a.none-line').count();
const rows = await page.locator('ul.width-135 > a.none-line');
for (let i = 0; i < count; ++i) {
await rows.nth(i).click()
await expect(page).toHaveURL(page.url());
console.log(page.url())
}
// 停止跟踪并将其导出到 zip 存档中。
await context.tracing.stop({ path: "trace.zip" })
});
https://playwright.dev/docs/api/class-playwright
https://github.com/microsoft/playwright
const http = require('http');
http.createServer(function (req, res) {
const { chromium, firefox, webkit } = require('playwright');
(async () => {
const browser = await chromium.launch(); // Or 'firefox' or 'webkit'.
const page = await browser.newPage();
await page.goto('http://www.good1230.com');
await page.screenshot({ path: `screenshot.png` }); // 图片默认保存到同当前文件的目录下
// other actions...
await browser.close();
})();
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('Node.js says hello!');
res.end();
}).listen(8080);