{"id":54659,"date":"2016-07-15T16:14:25","date_gmt":"2016-07-15T16:14:25","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=54659"},"modified":"2016-08-24T10:40:26","modified_gmt":"2016-08-24T10:40:26","slug":"how-to-use-phantomjs","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/","title":{"rendered":"How To Use PhantomJS &#8211; Part1"},"content":{"rendered":"<p>Today we will learn how to use PhantomJS, PhantomJS is a javascript library, that is used to automate the web page interaction. It is also called Handless Webkit Scripting language, reason behind this that we no need the GUI (Graphical User Interface) for performing the test. Handless means that output from the script will never displayed browser.<\/p>\n<p>PhantomJS is a CUI (Character User Interface) that is why output of a script always show on terminal.\u00a0 PhantomJS provides the JavaScript API, by which we can perform DOM handling and various operation.<\/p>\n<p>We can use PhantomJs in different cases:<\/p>\n<ol>\n<li><strong>Handless Testing :\u00a0<\/strong> We can use this technique to test the web application with command line output. We can also use Testing tool like Mocha, Casper with PhantomJS to extend the testing functionality.<\/li>\n<li><strong>Screen Capture : <\/strong>This feature can be use to capture the web pages of any website with different format. By using Phantomjs we can render anything on DOM. We can use PhantomJS not only to render\u00a0 the HTML or CSS but also with the Canvas.<\/li>\n<li><strong>Page Automation : <\/strong>By using PhantomJS, we can manipulate the web page&#8217;s content. By this features we can access the various content from the web pages, like we can get any textcontent by using the ID of that elements.<\/li>\n<li><strong>Network Monitoring : <\/strong>We can also monitor the network activity by Phantomjs. We can monitor the resource requests and responses by using <strong>onResourceRequested<\/strong> and <strong>onResourceReceived<\/strong><code>.<\/code><code class=\"highlighter-rouge\"><\/code><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>How to configure the PhantomJS on Linux:<\/p>\n<p>To install the PhantomJS on your system run the below command from terminal:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-54693\" src=\"http:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/07\/Screenshot_1-2.png\" alt=\"Screenshot_1\" width=\"493\" height=\"117\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/07\/Screenshot_1-2.png 493w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/07\/Screenshot_1-2-250x59.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/07\/Screenshot_1-2-300x71.png 300w\" sizes=\"(max-width: 493px) 100vw, 493px\" loading=\"lazy\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>After installation of phantomjs to know the version of phantomjs run the command from terminal:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-54694\" src=\"http:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/07\/Screenshot_2-1.png\" alt=\"Screenshot_2\" width=\"479\" height=\"79\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/07\/Screenshot_2-1.png 479w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/07\/Screenshot_2-1-250x41.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/07\/Screenshot_2-1-300x49.png 300w\" sizes=\"(max-width: 479px) 100vw, 479px\" loading=\"lazy\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today we will learn how to use PhantomJS, PhantomJS is a javascript library, that is used to automate the web page interaction. It is also called Handless Webkit Scripting language, reason behind this that we no need the GUI (Graphical User Interface) for performing the test. Handless means that output from the script will never <a href=\"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":34,"featured_media":41008,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[198],"tags":[3365],"class_list":["post-54659","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-phantomjs"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How To Use PhantomJS - Part1 - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Use PhantomJS - Part1 - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"Today we will learn how to use PhantomJS, PhantomJS is a javascript library, that is used to automate the web page interaction. It is also called Handless Webkit Scripting language, reason behind this that we no need the GUI (Graphical User Interface) for performing the test. Handless means that output from the script will never [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-15T16:14:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-08-24T10:40:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\" \/>\n\t<meta property=\"og:image:width\" content=\"825\" \/>\n\t<meta property=\"og:image:height\" content=\"260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Vivek Sharma\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vivek Sharma\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/\"},\"author\":{\"name\":\"Vivek Sharma\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/55a090ee89f2ea288152d9618972d51a\"},\"headline\":\"How To Use PhantomJS &#8211; Part1\",\"datePublished\":\"2016-07-15T16:14:25+00:00\",\"dateModified\":\"2016-08-24T10:40:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/\"},\"wordCount\":278,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\",\"keywords\":[\"Phantomjs\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/\",\"url\":\"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/\",\"name\":\"How To Use PhantomJS - Part1 - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\",\"datePublished\":\"2016-07-15T16:14:25+00:00\",\"dateModified\":\"2016-08-24T10:40:26+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png\",\"width\":825,\"height\":260},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Use PhantomJS &#8211; Part1\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/55a090ee89f2ea288152d9618972d51a\",\"name\":\"Vivek Sharma\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/016ec12a9caaedb7c6003878edfc412b2e9a5159e75bac4338ab7eeaaec9d92d?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/016ec12a9caaedb7c6003878edfc412b2e9a5159e75bac4338ab7eeaaec9d92d?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Vivek Sharma\"},\"sameAs\":[\"https:\/\/store.webkul.com\/\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/viveksh047\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Use PhantomJS - Part1 - Webkul Blog","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:\/\/webkul.com\/blog\/how-to-use-phantomjs\/","og_locale":"en_US","og_type":"article","og_title":"How To Use PhantomJS - Part1 - Webkul Blog","og_description":"Today we will learn how to use PhantomJS, PhantomJS is a javascript library, that is used to automate the web page interaction. It is also called Handless Webkit Scripting language, reason behind this that we no need the GUI (Graphical User Interface) for performing the test. Handless means that output from the script will never [...]","og_url":"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2016-07-15T16:14:25+00:00","article_modified_time":"2016-08-24T10:40:26+00:00","og_image":[{"width":825,"height":260,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","type":"image\/png"}],"author":"Vivek Sharma","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Vivek Sharma","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/"},"author":{"name":"Vivek Sharma","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/55a090ee89f2ea288152d9618972d51a"},"headline":"How To Use PhantomJS &#8211; Part1","datePublished":"2016-07-15T16:14:25+00:00","dateModified":"2016-08-24T10:40:26+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/"},"wordCount":278,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","keywords":["Phantomjs"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/","url":"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/","name":"How To Use PhantomJS - Part1 - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","datePublished":"2016-07-15T16:14:25+00:00","dateModified":"2016-08-24T10:40:26+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/02\/Opencart-Code-Snippet.png","width":825,"height":260},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/how-to-use-phantomjs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How To Use PhantomJS &#8211; Part1"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/55a090ee89f2ea288152d9618972d51a","name":"Vivek Sharma","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/016ec12a9caaedb7c6003878edfc412b2e9a5159e75bac4338ab7eeaaec9d92d?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/016ec12a9caaedb7c6003878edfc412b2e9a5159e75bac4338ab7eeaaec9d92d?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Vivek Sharma"},"sameAs":["https:\/\/store.webkul.com\/"],"url":"https:\/\/webkul.com\/blog\/author\/viveksh047\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/54659","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=54659"}],"version-history":[{"count":1,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/54659\/revisions"}],"predecessor-version":[{"id":54695,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/54659\/revisions\/54695"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media\/41008"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=54659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=54659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=54659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}