当前位置: 首页 > news >正文

找兼职工作在家做哪个网站好刚刚大连发生了大事

找兼职工作在家做哪个网站好,刚刚大连发生了大事,合肥知名网页制作公司,网站免费维护期是多少1.为什么使用go进行UI自动化测试#xff1f; 速度#xff1a;Go速度很快#xff0c;这在运行包含数百个UI测试的测试套件时是一个巨大的优势 并发性#xff1a;可以利用Go的内置并发性(goroutines)来并行化测试执行 简单#xff1a;Go的简约语法允许您编写可读且可维护… 1.为什么使用go进行UI自动化测试 速度Go速度很快这在运行包含数百个UI测试的测试套件时是一个巨大的优势 并发性可以利用Go的内置并发性(goroutines)来并行化测试执行 简单Go的简约语法允许您编写可读且可维护的测试脚本 ChromeDP一个无头Chrome/Chromium库允许直接从Go控制浏览器 2.什么是chromedp ChromeDP 是一个 Go 库允许开发者通过 Chrome DevTools 协议控制 Chrome/Chromium。借助 ChromeDP您可以与网页交互、模拟用户输入、浏览浏览器以及提取内容进行验证。它既可以在无头模式(没有浏览器UI)下工作也可以在有头模式(有可见浏览器)下工作。 3.设置环境 安装go brew install go 安装ChromeDP go get -u github.com/chromedp/chromedp 4.编写代码 示例测试 打开GoLand新建main.go文件 main.go-核心测试 这段代码将会打开Chrome导航到Google搜索页搜索Golang并验证Golang是否出现在搜索结果中 package mainimport (contextfmtgithub.com/chromedp/chromedpgithub.com/chromedp/chromedp/kblogstringstime )func main() {opts : chromedp.DefaultExecAllocatorOptions[:]opts append(opts,// Disable headless modechromedp.Flag(headless, false),// Enable GPU (optional)chromedp.Flag(disable-gpu, false),// Start with a maximized windowchromedp.Flag(start-maximized, true),)allocCtx, cancel : chromedp.NewExecAllocator(context.Background(), opts...)defer cancel()ctx, cancel : chromedp.NewContext(allocCtx)defer cancel()ctx, cancel context.WithTimeout(ctx, 15*time.Second)defer cancel()var result stringerr : chromedp.Run(ctx,chromedp.Navigate(https://www.google.com),chromedp.WaitVisible(//textarea[nameq]),chromedp.SendKeys(//textarea[nameq], Golang),chromedp.SendKeys(//textarea[nameq], kb.Enter),chromedp.WaitVisible(#search),chromedp.Text(#search, result),)if err ! nil {log.Fatal(err)}if strings.Contains(result, Golang) {fmt.Println(Test Passed: Golang found in search results)} else {fmt.Println(Test Failed: Golang not found in search results)} } Go测试框架编写多个UI测试 新建main_test.go文件 main_test.go-多种测试结果 测试用例 检查搜索结果是否包含术语“Golang”验证搜索栏是否在 Google 主页上可见检查空查询是否会导致没有搜索结果 package mainimport (contextgithub.com/chromedp/chromedpgithub.com/chromedp/chromedp/kbstringstestingtime )// checks that the search results contain Golang func TestGoogleSearch_Golang(t *testing.T) {opts : chromedp.DefaultExecAllocatorOptions[:]opts append(opts,chromedp.Flag(headless, false),chromedp.Flag(disable-gpu, false),chromedp.Flag(start-maximized, true),)allocCtx, cancel : chromedp.NewExecAllocator(context.Background(), opts...)defer cancel()ctx, cancel : chromedp.NewContext(allocCtx)defer cancel()ctx, cancel context.WithTimeout(ctx, 15*time.Second)defer cancel()var result stringerr : chromedp.Run(ctx,chromedp.Navigate(https://www.google.com),chromedp.WaitVisible(//textarea[nameq]),chromedp.SendKeys(//textarea[nameq], Golang),chromedp.SendKeys(//textarea[nameq], kb.Enter),chromedp.WaitVisible(#search),chromedp.Text(#search, result),)if err ! nil {t.Fatalf(Test Failed: %v, err)}if strings.Contains(result, Golang) {t.Log(Test Passed: Golang found in search results)} else {t.Errorf(Test Failed: Golang not found in search results)} }// checks that the search bar is visible func TestGoogleSearch_SearchBarVisible(t *testing.T) {opts : chromedp.DefaultExecAllocatorOptions[:]opts append(opts,chromedp.Flag(headless, false),chromedp.Flag(disable-gpu, false),chromedp.Flag(start-maximized, true),)allocCtx, cancel : chromedp.NewExecAllocator(context.Background(), opts...)defer cancel()ctx, cancel : chromedp.NewContext(allocCtx)defer cancel()ctx, cancel context.WithTimeout(ctx, 15*time.Second)defer cancel()err : chromedp.Run(ctx,chromedp.Navigate(https://www.google.com),chromedp.WaitVisible(//textarea[nameq]),)if err ! nil {t.Errorf(Test Failed: Search bar not visible - %v, err)} else {t.Log(Test Passed: Search bar is visible)} }// checks if there are results when the search query is empty func TestGoogleSearch_EmptyQuery(t *testing.T) {opts : chromedp.DefaultExecAllocatorOptions[:]opts append(opts,chromedp.Flag(headless, false),chromedp.Flag(disable-gpu, false),chromedp.Flag(start-maximized, true),)allocCtx, cancel : chromedp.NewExecAllocator(context.Background(), opts...)defer cancel()ctx, cancel : chromedp.NewContext(allocCtx)defer cancel()ctx, cancel context.WithTimeout(ctx, 15*time.Second)defer cancel()var result stringerr : chromedp.Run(ctx,chromedp.Navigate(https://www.google.com),chromedp.WaitVisible(//textarea[nameq]),chromedp.SendKeys(//textarea[nameq], ), // Empty querychromedp.SendKeys(//textarea[nameq], kb.Enter),chromedp.WaitVisible(#search, chromedp.ByID),chromedp.Text(#search, result),)if err ! nil {t.Fatalf(Test Failed: %v, err)}if result {t.Log(Test Passed: No search results for empty query)} else {t.Errorf(Test Failed: Unexpected results for empty query)} } 执行测试 将main.go和main_test.go放在同一目录然后执行命令 go test -v 测试结果
http://www.w-s-a.com/news/650872/

相关文章:

  • 手机网站标准百度搜索关键词排名优化推广
  • 中国空间站科幻作文1000字wordpress运行库
  • 徐州做网站的wordpress可视化编辑器排行
  • 官方网站英语上海公司注册核名查询
  • 东莞网站建设推广云南昆明最新消息
  • 上网站乱码网页设计与网站建设案例教程
  • 宣讲网站建设wordpress多媒体主题
  • 如何成立网站互联网开发是做什么的
  • 网站首页的尺寸做多大网页图片排版
  • 龙岩天宫山索道多少钱河南网站排名优化哪家好
  • 北京做网站设计程序员和网站开发
  • 个人 做自媒体 建网站图片制作成视频的手机软件
  • h5 建站网站 移动端重庆潼南网站建设价格
  • 商企在线营销型网站怎么做时光网站
  • 网站建设方案论文1500竞价托管哪家便宜
  • 使用cdn的网站宣武网站建设
  • 营销型网站怎么建设企业网站Wap在线生成
  • 网站建设服务费应该做到什么科目广州网页制作服务商
  • 网站显示500错误怎么解决方法店面设计模板
  • 网站备案icp文化传媒有限公司
  • 北京企业建站模板微信公众号商城怎么制作
  • 制作网站 公司简介大型做网站的公司
  • 北京网站开发建设南昌网站小程序开发
  • 网站如何做ip签名图片宁波互联网
  • 中山小榄网站建设长沙网络营销品牌排名
  • 推广优化厂商联系方式网站推广教程优化整站
  • 为外国企业做中文网站建设网站建设单位哪家好
  • 生物制药公司网站模板有没有专业做steam创客的网站
  • 福田做棋牌网站建设找哪家效益快弄一个微信小程序多少钱
  • 成都哪家做网站建设比较好做推广赚钱的网站