{"id":26318,"date":"2021-01-29T07:59:28","date_gmt":"2021-01-29T07:59:28","guid":{"rendered":"https:\/\/app14743.cloudwayssites.com\/?p=26318"},"modified":"2021-12-06T11:28:52","modified_gmt":"2021-12-06T19:28:52","slug":"playwright-java","status":"publish","type":"post","link":"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/","title":{"rendered":"Playing with Playwright &#8211; Java API and Playwright vs Selenium"},"content":{"rendered":"\n<p>Playwright, Microsoft&#8217;s new end-to-end browser automation framework, is making quite the splash! I took Playwright for a spin only a few months ago when it was a <a href=\"https:\/\/info.applitools.com\/uc4ys\">JavaScript-only framework<\/a>, and am pleasantly surprised to learn that language support has expanded to my beloved Java as well as Python and C#! ?<\/p>\n\n\n\n<p>I&#8217;ve also started to think about how to compare Playwright vs Selenium.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-playwright-vs-selenium\">Playwright vs Selenium<\/h2>\n\n\n\n<p>With the additional language support, as well as the ability to execute across modern browser engines Chromium, Firefox, and WebKit &#8211; this puts Playwright in the same category as Selenium WebDriver as viable testing solutions for all (not just JS) web testers who need cross-browser testing capabilities for complex applications.<\/p>\n\n\n\n<p>Browsing the <a href=\"https:\/\/www.javadoc.io\/doc\/com.microsoft.playwright\/playwright\/latest\/index.html\" target=\"_blank\" rel=\"noreferrer noopener\">Playwright Javadocs<\/a> was helpful, but I like to evaluate frameworks by actually using them to automate realistic scenarios. So in this post, I&#8217;ll share the steps of building a testing project with Playwright which includes Page Objects, and I&#8217;ll also compare the Playwright steps to their equivalents in Selenium WebDriver.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-install-playwright-java\">How to Install Playwright Java<\/h2>\n\n\n\n<p>The first step in getting started with Playwright is adding the dependency to your project. You can get the Playwright client from <a href=\"https:\/\/mvnrepository.com\/artifact\/com.microsoft.playwright\/playwright\/\" target=\"_blank\" rel=\"noreferrer noopener\">Maven Repository<\/a>. I created a new pom.xml file and added the playwright dependency.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/angiejones\/af0f739d020d99ee49961838ab8c6706.js\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/angiejones\/af0f739d020d99ee49961838ab8c6706\">Gist<\/a>.<\/noscript><\/div>\n<\/div><\/figure>\n\n\n\n<p>When it comes to comparing Selenium vs Playwright, it&#8217;s worth noting that like Selenium WebDriver, Playwright is a browser automation tool and not necessarily limited to a testing framework. In fact, neither of them provide any assertion methods. Therefore, you&#8217;ll need to add an assertion library as well. For this example, I&#8217;ll use <a href=\"https:\/\/mvnrepository.com\/artifact\/org.testng\/testng\" target=\"_blank\" rel=\"noreferrer noopener\">TestNG<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/angiejones\/88570851233fdb8db139c931db21d47f.js\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/angiejones\/88570851233fdb8db139c931db21d47f\">Gist<\/a>.<\/noscript><\/div>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-launch-browser-in-playwright\">How to Launch Browser in Playwright<\/h2>\n\n\n\n<p>The <em>Playwright<\/em> interface allows you to create specific types of <em>Browser<\/em> objects. The options are Chromium which is what Chrome and Edge are built upon, Firefox, and WebKit (the engine Safari is built upon). With this <em>Browser<strong> <\/strong><\/em>object, a <em>launch()<\/em> method is available which will start a browser instance.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/angiejones\/abfc846aed634f3917937952d5caec44.js\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/angiejones\/abfc846aed634f3917937952d5caec44\">Gist<\/a>.<\/noscript><\/div>\n<\/div><\/figure>\n\n\n\n<p>By default, Playwright launches the browser in headless mode, which means you won&#8217;t actually see the tests execute. If you want to see the browser open, you can disable headless mode by passing in a <em>LaunchOption.<\/em><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/angiejones\/f26a970e673e3e92d8695333596a2e63.js\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/angiejones\/f26a970e673e3e92d8695333596a2e63\">Gist<\/a>.<\/noscript><\/div>\n<\/div><\/figure>\n\n\n\n<p>In addition to setting the headless mode, <a href=\"https:\/\/www.javadoc.io\/doc\/com.microsoft.playwright\/playwright\/latest\/com\/microsoft\/playwright\/BrowserType.LaunchOptions.html\" target=\"_blank\" rel=\"noreferrer noopener\">LaunchOptions<\/a> provide several other methods including ones to set environment variables and open Chromium dev tools.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-launch-a-website-in-playwright\">How to Launch a Website in Playwright<\/h2>\n\n\n\n<p>Now that we have a browser, we can load the application under test &#8211; <a href=\"https:\/\/automationbookstore.dev\/\" target=\"_blank\" rel=\"noreferrer noopener\">Automation Bookstore<\/a>. To do so, we need a <em>Page<\/em> object &#8211; which is similar to the <em>WebDriver<\/em> objects in Selenium. To create the <em>Page<\/em> object, we call <em>browser.newPage()<\/em> on line 8. This represents a single tab within the browser window. With this object, we can then navigate to our URL (line 9).<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/angiejones\/f2686fc54d93ba891c6ec7c454556151.js\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/angiejones\/f2686fc54d93ba891c6ec7c454556151\">Gist<\/a>.<\/noscript><\/div>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-create-a-page-object-in-playwright\">How to Create a Page Object in Playwright<\/h2>\n\n\n\n<p>We have our application loaded in the browser, and now we&#8217;d like to use the <a href=\"https:\/\/angiejones.tech\/page-object-model\/\" target=\"_blank\" rel=\"noreferrer noopener\">Page Object Model design pattern<\/a> to create a Java class that represents the Search page of our application.<\/p>\n\n\n\n<p>In order to interact with the web elements, the Page Object class will need access to the Playwright <em>Page<\/em> object we created above. Again, this is comparable to how we pass the Selenium <em>WebDriver<\/em> object to Page Object classes so that they can perform browser interaction methods.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/angiejones\/f01d7d02e64f08e3e692e8fd74ac65ef.js\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/angiejones\/f01d7d02e64f08e3e692e8fd74ac65ef\">Gist<\/a>.<\/noscript><\/div>\n<\/div><\/figure>\n\n\n\n<p>I created that <em>SearchPage<\/em> class and the constructor that accepts the <em>Page<\/em> object.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/angiejones\/6d16b27db88504694853f7ba853445ff.js\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/angiejones\/6d16b27db88504694853f7ba853445ff\">Gist<\/a>.<\/noscript><\/div>\n<\/div><\/figure>\n\n\n\n<p>The first method I&#8217;ll add to this class is <em>search()<\/em> which will take in text and enter it into a text field. The method to do this is <em>fill(), <\/em>which takes a locator and the text you&#8217;d like entered into the field. You can see the call on line 11.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/angiejones\/79844b19d8fd0eec81fb5d0c71b1967b.js\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/angiejones\/79844b19d8fd0eec81fb5d0c71b1967b\">Gist<\/a>.<\/noscript><\/div>\n<\/div><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-locators\">Locators<\/h3>\n\n\n\n<p>The element locator for the search field is defined as a String. This is true for all locators used in Playwright; unlike Selenium which uses the <em>By<\/em> class to allow you to express locators as id, name, XPath, css selector, link text, etc. However, Playwright offers a <a href=\"https:\/\/playwright.dev\/docs\/selectors\/\" target=\"_blank\" rel=\"noreferrer noopener\">variety of options to express the locators<\/a> so all of the ones in Selenium are covered, plus extra flexibility for more expressive locators such as conditions of the elements, chaining, and even access to shadow DOM elements!<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-wait-strategies\">Wait Strategies<\/h3>\n\n\n\n<p>Playwright has <a href=\"https:\/\/playwright.dev\/docs\/actionability\" target=\"_blank\" rel=\"noreferrer noopener\">auto-waiting<\/a> for elements that you are directly interacting with. Selenium WebDriver often gets a bad rap for things that are out of its control, for example the need to wait for a desired state of the application. In my particular application, there is a slight delay between the time I enter the search query and the time that the results are filtered. Since the search results element is a different element than the one I used the automation tool to interact with (search field), I have to account for this wait in my code, and it doesn&#8217;t matter if I use Selenium, Cypress, or Playwright &#8211; this remains true.<\/p>\n\n\n\n<p>To wait within Playwright, there&#8217;s a <em><a href=\"https:\/\/www.javadoc.io\/doc\/com.microsoft.playwright\/playwright\/latest\/com\/microsoft\/playwright\/Page.WaitForSelectorOptions.html\" target=\"_blank\" rel=\"noreferrer noopener\">WaitForSelectorOptions<\/a><\/em> class that allows you to specify the state you&#8217;re waiting for. The <a href=\"https:\/\/www.javadoc.io\/static\/com.microsoft.playwright\/playwright\/0.180.0\/com\/microsoft\/playwright\/Page.WaitForSelectorOptions.State.html\" target=\"_blank\" rel=\"noreferrer noopener\">available states<\/a> are ATTACHED, DETACHED, HIDDEN, and VISIBLE.<\/p>\n\n\n\n<p>So here, after entering text into the field, I need to ask Playwright to wait until there are hidden books attached to the DOM. This is shown on lines 4-5.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/angiejones\/fa413dae21f67c0b76e6cd2f3b3db735.js\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/angiejones\/fa413dae21f67c0b76e6cd2f3b3db735\">Gist<\/a>.<\/noscript><\/div>\n<\/div><\/figure>\n\n\n\n<p>To demonstrate the <em>DETACHED<\/em> selector option, I&#8217;ll also make a <em>clear()<\/em> method. In this method, I clear the text field by sending an empty String, then wait for the hidden books element to be detached from the DOM.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/angiejones\/ea490f8821f5bd9a6593ef2216421a9b.js\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/angiejones\/ea490f8821f5bd9a6593ef2216421a9b\">Gist<\/a>.<\/noscript><\/div>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-get-elements-in-playwright\">How to Get Elements in Playwright<\/h2>\n\n\n\n<p>Playwright provides the <em>querySelector()<\/em> mehod which returns a single element as an <em>ElementHandle<\/em> object. This is equivalent to Selenium&#8217;s <em>WebElement<\/em> object obtained by <em>findElement()<\/em>. To get multiple elements that match the locator, Playwright provides <em>querySelectorAll()<\/em> and this will return a list of elements: <em>List&lt;ElementHandle&gt;.<\/em><\/p>\n\n\n\n<p>This is demonstrated in our Page Object class as we get the number of visible books.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/angiejones\/9b676af6e4dfe396721839d8889bff13.js\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/angiejones\/9b676af6e4dfe396721839d8889bff13\">Gist<\/a>.<\/noscript><\/div>\n<\/div><\/figure>\n\n\n\n<p>From an <em>ElementHandle<\/em>, you can take actions (e.g. click, fill, etc) or get information (getAttribute, isEnabled, isChecked, etc). The two methods that are JavaScripty and maybe not obvious at first glance to Java programmers are:<em> innerText()<\/em> and <em>innerHTML()<\/em>. The <em>innerText()<\/em> method is equivalent to Selenium&#8217;s getText() method; and there is no equivalent for <em>innerHTML()<\/em> in Selenium, but it&#8217;s used to get the entire HTML contained between an element&#8217;s opening and closing tags.<\/p>\n\n\n\n<p>Here I use the <em>innerText()<\/em> method to get the titles of the visible books on line 4.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/angiejones\/53fb0225c8ed0f8433b6793c5923dc60.js\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/angiejones\/53fb0225c8ed0f8433b6793c5923dc60\">Gist<\/a>.<\/noscript><\/div>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-the-tests\">The Tests<\/h2>\n\n\n\n<p>Now that all of the heavy lifting has been done in the BaseTests and Page Object classes, the tests look exactly like they would if written in Selenium.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/angiejones\/746425b97b7d89523ec0f3c6c6b98f27.js\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/angiejones\/746425b97b7d89523ec0f3c6c6b98f27\">Gist<\/a>.<\/noscript><\/div>\n<\/div><\/figure>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link\" href=\"https:\/\/github.com\/angiejones\/playwright-java\" target=\"_blank\" rel=\"noreferrer noopener\">Get source code<\/a><\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-there-s-much-more\">There&#8217;s Much More<\/h2>\n\n\n\n<p>What I&#8217;ve demonstrated here is how to use Playwright for some of the most common everyday tasks, however the API boasts a lot more! It can capture screenshots, mock geolocation, emulate mobile device settings, intercept network calls, and <a href=\"https:\/\/github.com\/microsoft\/playwright-java\" target=\"_blank\" rel=\"noreferrer noopener\">much more<\/a>. When comparing Playwright vs Selenium, Playwright already contains a lot of the features that make Selenium 4 more modern. While Playwright is still very new, it looks extremely promising and I&#8217;m definitely keeping my eye on it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Playwright open source automation framework has released a Java API for cross-browser end-to-end testing! See how to install Playwright, create tests, and implement the Page Object Model design pattern.<\/p>\n","protected":false},"author":31,"featured_media":26368,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[12271],"tags":[10084,16634,16608,10139],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v24.5 (Yoast SEO v24.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Playing with Playwright Java | Playwright vs Selenium - AI-Powered End-to-End Testing | Applitools<\/title>\n<meta name=\"description\" content=\"The Playwright open source automation framework has released a Java API! See how to get started and we&#039;ll compare Playwright vs Selenium.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Playing with Playwright - Java API and Playwright vs Selenium\" \/>\n<meta property=\"og:description\" content=\"The Playwright open source automation framework has released a Java API for cross-browser end-to-end testing! See how to install Playwright, create tests, and implement the Page Object Model design pattern.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/\" \/>\n<meta property=\"og:site_name\" content=\"AI-Powered End-to-End Testing | Applitools\" \/>\n<meta property=\"article:published_time\" content=\"2021-01-29T07:59:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-12-06T19:28:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/01\/playwright-java.png\" \/>\n\t<meta property=\"og:image:width\" content=\"831\" \/>\n\t<meta property=\"og:image:height\" content=\"542\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Angie Jones\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Angie Jones\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/\"},\"author\":{\"name\":\"Angie Jones\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#\/schema\/person\/bef60d60f816d3253a3e37120c0b9bba\"},\"headline\":\"Playing with Playwright &#8211; Java API and Playwright vs Selenium\",\"datePublished\":\"2021-01-29T07:59:28+00:00\",\"dateModified\":\"2021-12-06T19:28:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/\"},\"wordCount\":1357,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/01\/playwright-java.png\",\"keywords\":[\"JAVA\",\"page object model\",\"Playwright\",\"Selenium\"],\"articleSection\":[\"Getting Started\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/\",\"url\":\"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/\",\"name\":\"Playing with Playwright Java | Playwright vs Selenium - AI-Powered End-to-End Testing | Applitools\",\"isPartOf\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/01\/playwright-java.png\",\"datePublished\":\"2021-01-29T07:59:28+00:00\",\"dateModified\":\"2021-12-06T19:28:52+00:00\",\"description\":\"The Playwright open source automation framework has released a Java API! See how to get started and we'll compare Playwright vs Selenium.\",\"breadcrumb\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/#primaryimage\",\"url\":\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/01\/playwright-java.png\",\"contentUrl\":\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/01\/playwright-java.png\",\"width\":831,\"height\":542},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/app14743.cloudwayssites.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Getting Started\",\"item\":\"https:\/\/app14743.cloudwayssites.com\/blog\/category\/getting-started\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Playing with Playwright &#8211; Java API and Playwright vs Selenium\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#website\",\"url\":\"https:\/\/app14743.cloudwayssites.com\/\",\"name\":\"Applitools Visual AI\",\"description\":\"Applitools delivers full end-to-end test automation with AI infused at every step.\",\"publisher\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/app14743.cloudwayssites.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#organization\",\"name\":\"Applitools\",\"url\":\"https:\/\/app14743.cloudwayssites.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2020\/03\/applitools.png\",\"contentUrl\":\"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2020\/03\/applitools.png\",\"width\":156,\"height\":28,\"caption\":\"Applitools\"},\"image\":{\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#\/schema\/person\/bef60d60f816d3253a3e37120c0b9bba\",\"name\":\"Angie Jones\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/app14743.cloudwayssites.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/60864923503620d0b54e2493ef75b9d8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/60864923503620d0b54e2493ef75b9d8?s=96&d=mm&r=g\",\"caption\":\"Angie Jones\"},\"url\":\"https:\/\/app14743.cloudwayssites.com\/blog\/author\/angiejones\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Playing with Playwright Java | Playwright vs Selenium - AI-Powered End-to-End Testing | Applitools","description":"The Playwright open source automation framework has released a Java API! See how to get started and we'll compare Playwright vs Selenium.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/","og_locale":"en_US","og_type":"article","og_title":"Playing with Playwright - Java API and Playwright vs Selenium","og_description":"The Playwright open source automation framework has released a Java API for cross-browser end-to-end testing! See how to install Playwright, create tests, and implement the Page Object Model design pattern.","og_url":"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/","og_site_name":"AI-Powered End-to-End Testing | Applitools","article_published_time":"2021-01-29T07:59:28+00:00","article_modified_time":"2021-12-06T19:28:52+00:00","og_image":[{"width":831,"height":542,"url":"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/01\/playwright-java.png","type":"image\/png"}],"author":"Angie Jones","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Angie Jones","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/#article","isPartOf":{"@id":"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/"},"author":{"name":"Angie Jones","@id":"https:\/\/app14743.cloudwayssites.com\/#\/schema\/person\/bef60d60f816d3253a3e37120c0b9bba"},"headline":"Playing with Playwright &#8211; Java API and Playwright vs Selenium","datePublished":"2021-01-29T07:59:28+00:00","dateModified":"2021-12-06T19:28:52+00:00","mainEntityOfPage":{"@id":"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/"},"wordCount":1357,"commentCount":0,"publisher":{"@id":"https:\/\/app14743.cloudwayssites.com\/#organization"},"image":{"@id":"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/#primaryimage"},"thumbnailUrl":"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/01\/playwright-java.png","keywords":["JAVA","page object model","Playwright","Selenium"],"articleSection":["Getting Started"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/","url":"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/","name":"Playing with Playwright Java | Playwright vs Selenium - AI-Powered End-to-End Testing | Applitools","isPartOf":{"@id":"https:\/\/app14743.cloudwayssites.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/#primaryimage"},"image":{"@id":"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/#primaryimage"},"thumbnailUrl":"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/01\/playwright-java.png","datePublished":"2021-01-29T07:59:28+00:00","dateModified":"2021-12-06T19:28:52+00:00","description":"The Playwright open source automation framework has released a Java API! See how to get started and we'll compare Playwright vs Selenium.","breadcrumb":{"@id":"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/#primaryimage","url":"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/01\/playwright-java.png","contentUrl":"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2021\/01\/playwright-java.png","width":831,"height":542},{"@type":"BreadcrumbList","@id":"https:\/\/app14743.cloudwayssites.com\/blog\/playwright-java\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/app14743.cloudwayssites.com\/"},{"@type":"ListItem","position":2,"name":"Getting Started","item":"https:\/\/app14743.cloudwayssites.com\/blog\/category\/getting-started\/"},{"@type":"ListItem","position":3,"name":"Playing with Playwright &#8211; Java API and Playwright vs Selenium"}]},{"@type":"WebSite","@id":"https:\/\/app14743.cloudwayssites.com\/#website","url":"https:\/\/app14743.cloudwayssites.com\/","name":"Applitools Visual AI","description":"Applitools delivers full end-to-end test automation with AI infused at every step.","publisher":{"@id":"https:\/\/app14743.cloudwayssites.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/app14743.cloudwayssites.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/app14743.cloudwayssites.com\/#organization","name":"Applitools","url":"https:\/\/app14743.cloudwayssites.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/app14743.cloudwayssites.com\/#\/schema\/logo\/image\/","url":"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2020\/03\/applitools.png","contentUrl":"https:\/\/app14743.cloudwayssites.com\/wp-content\/uploads\/2020\/03\/applitools.png","width":156,"height":28,"caption":"Applitools"},"image":{"@id":"https:\/\/app14743.cloudwayssites.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/app14743.cloudwayssites.com\/#\/schema\/person\/bef60d60f816d3253a3e37120c0b9bba","name":"Angie Jones","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/app14743.cloudwayssites.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/60864923503620d0b54e2493ef75b9d8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/60864923503620d0b54e2493ef75b9d8?s=96&d=mm&r=g","caption":"Angie Jones"},"url":"https:\/\/app14743.cloudwayssites.com\/blog\/author\/angiejones\/"}]}},"_links":{"self":[{"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/posts\/26318"}],"collection":[{"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/users\/31"}],"replies":[{"embeddable":true,"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/comments?post=26318"}],"version-history":[{"count":0,"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/posts\/26318\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/media\/26368"}],"wp:attachment":[{"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/media?parent=26318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/categories?post=26318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app14743.cloudwayssites.com\/wp-json\/wp\/v2\/tags?post=26318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}