Microsoft: Playwright for Python language lets you test web apps in all major browsers

Microsoft has announced Playwright, a tool that lets developers write tests in Python for web applications across Chrome, Chromium-based Edge, Apple Safari and Mozilla Firefox. 

Playwright, a Python library, allows developers to essentially control the browser with a few lines of Python code to automate cross-browser testing for single-page web apps and Progressive Web Apps. 

The Playwright for Python library is available in preview and is designed to help accelerate the process of testing web applications across Windows, Linux and macOS. It can also be used to emulate smartphones with different screen sizes, timezones, and web permissions to test a web app in mobile web browsers.

SEE: Hiring Kit: Python developer (TechRepublic Premium)

It provides a set of application programming interfaces (APIs) to automate browsers that use the Chromium, Firefox and WebKit browser engines. Using the Playwright API, developers can write Python code to create new browser pages, navigate to URLs and interact with elements on a page. 

“With the Playwright API, you can author end-to-end tests that run on all modern web browsers. Playwright delivers automation that is faster, more reliable and more capable than existing testing tools,” says Arjun Attam, a program manager for Playwright

“Automated end-to-end tests have become more important than ever before. Teams are shipping faster and building apps that run on a growing set of devices. This increase in velocity and web targets puts immense pressure on the testing process, and automation is critical.”

While presently Playwright only supports mobile emulation from a desktop browser, there is an open issue on Microsoft’s GitHub page for Playwright that users can upvote to bring support for testing on actual mobile browsers. 

Playwright integrates with the pytest testing framework and can be used to test views in Django web apps as well as use Django’s built-in testing tools. 

The Playwright for Python release is in its early stages and builds on the release easier this year of Playwright for JavaScript and Microsoft’s JavaScript superset TypeScript in the form of a Node.js library. It serves the same purpose as Playwright for Python, but allows testing routines to be written in JavaScript.

SEE: Programming languages: Julia users most likely to defect to Python for data science

Importantly for automated testing, Playwright waits for the web app’s UI to be ready to handle testing actions like clicking a button, which needs to be there before its functionality can be tested. It can also be used to automate tests for logging in to a web app on a login form.     

“Under the hood, Playwright uses an event-driven architecture that can listen to precise browser events like DOM changes, network requests and page navigations,” notes Attam. 

Playwright also provides standard interfaces to monitor and modify network traffic for testing tasks like handling attachments downloaded by a page and a network response after a user clicks a button.

More on Python and programming languages

  • Python programming language: Here’s what’s new in version 3.9 RC2
  • Python programming: Microsoft’s latest beginners’ course looks at developing for NASA projects  
  • Programming language popularity: Python overtakes Java – as Rust reaches top 20  
  • Top programming languages: Python still rules but old Cobol gets a pandemic bump  
  • Kotlin programming language: How Google is using it to squash the code bugs that cause most crashes  
  • Microsoft: We’re pulling the plug on Windows builds of programming language PHP  
  • Kotlin programming language: Google offers free course for Android development  
  • Programming languages: Now Rust project looks for a way into the Linux kernel  
  • Programming language rankings: R makes a comeback but there’s debate about its rise  
  • Programming languages: Julia touts its speed edge over Python and R  
  • Microsoft lead engineer: Programming language TypeScript took off thanks to Google’s Angular  
  • JavaScript creator Eich: My take on 20 years of the world’s top programming language  
  • Programming languages: Java still rules over Python and JavaScript as primary language  
  • Julia programming language: Users reveal what they love and hate the most about it    
  • Mozilla is funding a way to support Julia in Firefox
  • MIT: We’re building on Julia programming language to open up AI coding to novices
  • Programming languages: Developers reveal what they love and loathe, and what pays best  
  • Programming languages: Rust enters top 20 popularity rankings for the first time  
  • Microsoft: Here’s why we love programming language Rust and kicked off Project Verona  
  • Microsoft: Bosque is a new programming language built for AI in the cloud  
  • Programming languages: Python apps might soon be running on Android  
  • Is Julia the next big programming language? MIT thinks so, as version 1.0 lands TechRepublic  
  • Mozilla’s radical open-source move helped rewrite rules of tech CNET
  • LEAVE A REPLY

    Please enter your comment!
    Please enter your name here