What is the difference between Playwright and Selenium?

foreword

Recently, many students have asked what is the difference between Playwright and Selenium?
Some students may have learned selenium before, and it feels redundant to learn another playwright. Maybe some projects have been written in selenium before. Switching to playwright will take time and cost, and there may be unknown risks.
There are also students who may not have learned selenium before, and are now preparing to start a web automation framework, but are hesitant to choose selenium and playwright, because there are many interview questions about selenium, and they may not be used at work after learning, just for interviews.
Regardless of the reason, this article analyzes the differences between the two in detail

Difference between Playwright and Selenium

serial number Function Playwright Selenium which is better
1 learning materials relatively few many Selenium
2 Client Appeared relatively late, the number of users is relatively small Appeared early, with a large number of users Selenium
3 language support TypeScript、JavaScript、Python、.NET、Java C#, Java, Perl, PHP, Python and Ruby Selenium
4 Support browser Chromium (including chrome, msedge), WebKit and Firefox Internet Explorer (7, 8, 9, 10, 11), Firefox, Safari, Google Chrome, Opera, Edge, etc. Selenium
5 Cross-platform Windows, Linux (only some Ubuntu systems are supported), Mac Windows, Linux, Mac are all supported Selenium
6 browser installation command line installation install yourself Playwright
7 browser driver no driver required Download the corresponding version driver Playwright
8 startup speed quick slow Playwright
9 context environment isolation have none Playwright
10 headless headless mode The default is headless, you can also set the GUI Default GUI mode, you can also set headless Playwright
11 incognito mode The default incognito mode is very helpful for corresponding tests. For crawler users, access to the page may not pass The default is non-incognito, crawler users especially like it Selenium
12 page waiting wait_for_load_state can accurately wait for the four states of commit, domcontentloaded, load, and networkidle implicitly_wait waits for the page to load Playwright
13 element positioning Provide multiple built-in locators, the positioning method is closer to the business, and there are more positioning methods Eight positioning Playwright
14 element wait Positioning elements have their own waiting mechanism You need to encapsulate the waiting method yourself Playwright
15 Click on elements etc. Will judge the status of the element, where it appears, and whether it can be clicked for intelligent judgment It is difficult to encapsulate the webdriverwait.until method by yourself Playwright
16 positioning error It will humanize and tell you how many elements to locate, and recommend the positioning method To report an error, you need to guess the riddle by yourself and rule out all possibilities by yourself Playwright
17 Element is not on the current screen It will judge the position of the element and automatically scroll the position where the element appears You need to judge by yourself Playwright
18 iframe Operate through objects without switching need to switch back and forth Playwright
19 alert The default monitoring is automatically closed, and it can be monitored asynchronously You need to judge by yourself, no asynchronous monitoring Playwright
20 File Upload Monitor file upload time, handle gracefully Unable to resolve non-input uploads Playwright
21 Download Document Can monitor downloads Can only set browser default location Playwright
22 Multi-window tab Can monitor window events, easy to operate need to switch back and forth Playwright
23 event listener Various events can be monitored unable to monitor Playwright
24 capture ajax request Can capture ajax request and return unable to capture Playwright
25 mock function Can simulate any interface data you want No mock function Playwright
26 Affirmation Provide expect rich assertion It is difficult to encapsulate the webdriverwait.until method by yourself Playwright
27 record video Record a use case video none Playwright
28 trace trace have none Playwright
29 breakpoint debugging have none Playwright
30 to record Can generate pytest use cases The recording function is relatively simple Playwright
31 Mouse and keyboard operation Easy to call Importing modules is complicated Playwright
32 base_url Global base_url can be added no such function Playwright
33 interface test Provide interface testing no such function Playwright
34 grid distributed none selenium-grid distributed Selenium
35 protocol Websockt protocol, which can get page status in real time The http protocol can only get the status at that time, you need to poll and judge by yourself Playwright
36 execute javascript JavaScript can be executed on page, iframe, and element objects JavaScript can only be executed on the driver object Playwright
37 interview Requires less playwright Ask selenium more Selenium
38 Learning Difficulty 容易,无需封装,直接用 难度较大,需要封装 Playwright

总体打分Selenium 8分, Playwright 30 分,如果你是新手,毫不犹豫应该直接学playwright

最后:下方这份完整的软件测试视频学习教程已经整理上传完成,朋友们如果需要可以自行免费领取【保证100%免费】

在这里插入图片描述

软件测试面试文档

我们学习必然是为了找到高薪的工作,下面这些面试题是来自阿里、腾讯、字节等一线互联网大厂最新的面试资料,并且有字节大佬给出了权威的解答,刷完这一套面试资料相信大家都能找到满意的工作。

图片

Guess you like

Origin blog.csdn.net/weixin_50829653/article/details/130600398