网站图片如何居中,做360手机网站优化快,深圳办公室装修设计,养生网站设计后续代码会整理开源-大家期待吧#xff01;#xff01;#xff01;
首先讲下为啥不用python#xff0c;因为不想下载各种安装插件#xff0c;太麻烦了#xff0c;好多不兼容。
所以选择了java。
先来讲下什么是playwright#xff0c;playwright是微软开源自动化测试工…后续代码会整理开源-大家期待吧
首先讲下为啥不用python因为不想下载各种安装插件太麻烦了好多不兼容。
所以选择了java。
先来讲下什么是playwrightplaywright是微软开源自动化测试工具Playwright,支持主流浏览器,包括:CHnrome、Firefox、Safari等,同时支持以无头模式、有头模式运行,并提供了同步、异步的API,可以结合主流测试框架使用,并且支持浏览器端的自动化脚本录制等功能。
特点: 1、跨浏览器:Playwright支持所有现代渲染引擎,包括Chromhium、WebKit 和 Firefox ;跨平台:在Windows、Linux和MacOS 上进行本地或CI、无头或有头测试跨语言:在TypeScript、JavaScript、Python、.NET、Java 中使用 Playwright API 3、测试移动网络:适用于Android和MobileSafari的Googlle Chrome 原生移动仿真。相同的渲染引擎适用于您的桌面和云 端。 官网地址: https://playwright.dev GitHub地址: https://github.com/microsoft/playwright 大白话:playwright就是一款主流的自动化测试工具,可以跨平台、跨语言、开源、支持分布式、拥有成熟的社区及学习文档,主要用于接口API测试和web自动化测试。
第一步新建maven项目
maven项目新增playWright如下
POM.xml
?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd modelVersion4.0.0/modelVersion groupIdorg.kingzzzz/groupId artifactIdexamples/artifactId version0.1-SNAPSHOT/version namePlaywright Client Examples/name properties project.build.sourceEncodingUTF-8/project.build.sourceEncoding /properties dependencies dependency groupIdcom.microsoft.playwright/groupId artifactIdplaywright/artifactId version1.49.0/version /dependency /dependencies build plugins plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-compiler-plugin/artifactId version3.10.1/version configuration source1.8/source target1.8/target /configuration /plugin /plugins /build /project 第二步新建类写第一个demo
package org.example;
import com.microsoft.playwright.*;
public class App { public static void main(String[] args) { try (Playwright playwright Playwright.create()) { Browser browser playwright.chromium().launch(); Page page browser.newPage(); page.navigate(http://playwright.dev); System.out.println(page.title()); } } } 使用命令去编译程序或者直接run main方法都可。
打印如下图第一个demo就成功了大大家可以试试啦。