V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  DiamondYuan  ›  全部回复第 1 页 / 共 12 页
回复总数  227
1  2  3  4  5  6  7  8  9  10 ... 12  
分享一下我的思路。 同样是给予 playwright 实现
测试用例是基于自然语言的



await page.goto(`https://www.baidu.com/`);
const testWriter = new TestWriter();
await testWriter.run('选中输入框', await buildContext(page));
await testWriter.run('输入你好', await buildContext(page));
await testWriter.run('点击搜索', await buildContext(page));



testWriter 在执行的时候,我会把当前页面的截图提供给 ai 。 并且提供一系列的 tools 给 ai , 让 ai 自己编写代码

const description = `
1. the code is sent to playwright's page.evaluate(code) to execute.
2. The result will be serialised to json. Only the first 500 characters will be returned.
3. The result must be serialisable.
4. Please don't define a function
5. Don't write the await function
`;

export const evaluateCodeInPage = (page: Page): RunnerTool<string> => {
return {
definition: {
type: 'function',
function: {
name: 'evaluateCodeInPage',
description: description,
parameters: {
type: 'object',
properties: {
code: {
type: 'string',
description: 'JavaScript code to evaluate in the page context. will call page.evaluate(code)',
},
},
},
},
},
toolCall: async (args: string) => {
const { code } = JSON.parse(args);
const result = await page.evaluate(code);
return {
content: JSON.stringify(result).slice(0, 1000),
};
},
};
};


ai 自动根据 evaluateCodeInPage 查找页面元素是否存在,自动编写 playweight 的脚本。
编写好脚本后,会调用 SaveCodeTool 把测试脚本保存在本地

export const SaveCodeTool: openai.ChatCompletionTool = {
type: 'function',
function: {
name: 'saveCode',
description: '保存代码',
parameters: {
type: 'object',
properties: {
fileName: { type: 'string', description: 'no extension' },
code: { type: 'string' },
},
},
},
};


下一次运行的时候,就完全不需要 AI 了。 只需要执行测试脚本即可。
有些 ai 写不对的地方,也可以人肉帮 ai 写一下。



未来会在这里开源 https://github.com/mockforge/testforge
1 天前
回复了 maijiawei 创建的主题 全球工单系统 cursor 挂了吗?
可以用 deepkseek + cline 暂时替代。
rank 15 的是 just-js , 居然是 js
推荐 CapRover , 基于 docker 开发的。

优点是开源免费,架构简单。 可以免去配证书的麻烦事。
出了图形界面,还有 cli ,可以自己和 GitHub action 组合,搞 CICD 。
197 天前
回复了 DiamondYuan 创建的主题 程序员 开源一个前端 mock 工具
@foolishcrab

mock 数据和代码是放在一起的,方便写测试,本地管理。

通过 npm 集成,可以让所有维护者都不需要安装插件。
197 天前
回复了 DiamondYuan 创建的主题 程序员 开源一个前端 mock 工具
@iosyyy

会在 html 里注入脚本,拦截全部的 xhr 请求。(公司内项目都是 axios ,没用 fetch ,所以我第一版只拦截了 xhr )

如果和配置的 mock 匹配,就会用 mock 数据。
221 天前
回复了 DiamondYuan 创建的主题 问与答 入职新公司,买 mac mini 还是 mac book air
@IvanLi127
@zhhmax
@Foxkeh


主要是想换一台内存大一点的,专门买一台,然后装公司的软件入网。
目前 m1 正常不卡,就是想体验更好一点。
221 天前
回复了 DiamondYuan 创建的主题 问与答 入职新公司,买 mac mini 还是 mac book air
@murmur 电脑性能好,在公司开发也开心一点。
230 天前
回复了 afanda1234 创建的主题 求职 求职 [北上深杭][前端、全栈] 9 年经验求职
https://www.v2ex.com/t/1062756#reply1

上海蚂蚁,招偏后端的前端。
231 天前
回复了 boris1993Jr 创建的主题 程序员 今天在小红书看到个逆天的
突然 6 年前发现我也水过这个项目。

https://github.com/kubernetes/website/pull/7680
https://github.com/popomore/projj


我推荐 projj . + projj hooks


projj add git@github.com:popomore/projj.git

项目会自动放在 github.com/popomore/projj 里。



{
"hooks": {
"git_config_user": "projj_git_config_user"
},
"git_config_user": {
"github.com": {
"name": "your name",
"email": "your email",
"signingkey": "your signingkey"
}
}
}

题主的需求可以通过 hooks 来解决,add 的时候可以自动根据域名来决定使用公司邮箱还是个人邮箱。
255 天前
回复了 imherer 创建的主题 程序员 ts 里类似 golang 这种写法怎么实现?
class Status {
construtor ( private value:number ,private label:string )


toString (){
return this.label


valueOf (){
return this.value






const success = new Status ( 1 ,“成功”)
268 天前
回复了 xpa 创建的主题 程序员 阿里的 OSS 文档好乱
@vituralfuture

这种一般都是网关统一转发,不遵守 restful 协议,只是把 http 当成通信信道。
页面最顶层放一个 context
我也是这么想的, 写过 java ,golang ,js ,rust ,ts

目前最喜欢的也是 TypeScript 。 除了对性能要求高的地方,替他代码都可以用 ts 。

TS 还有一个好处就是编译后的 js 可以直接在浏览器里运行,开发 web 应用很方便。
阿里巴巴和蚂蚁集团分家了,可以分开。
这不就是 mod ? 游戏提供 api ,开发者编写 mod 代码,上传到创意工坊。 其他人可以订阅 mod
276 天前
回复了 sdjl 创建的主题 推广 《为什么你应该立即使用云开发写小程序?》
@wonderfulcxm

比如说支付宝小程序云,也支持云开发。

可以发布 http 接口
可以试试看支付宝小程序云 https://cloud.alipay.com/main/home
vscode 是创建了一个隐藏的 input ,当你点击编辑器的时候,就会 focus 这个 input ,然后用 js 画一个光标出来。

所有的事件会被这个 input 捕获,通过一写计算后,计算出新 input 的位置,然后渲染出来。
1  2  3  4  5  6  7  8  9  10 ... 12  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2782 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 34ms · UTC 10:01 · PVG 18:01 · LAX 03:01 · JFK 06:01
Developed with CodeLauncher
♥ Do have faith in what you're doing.