{"id":72591,"date":"2017-01-25T12:50:34","date_gmt":"2017-01-25T12:50:34","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=72591"},"modified":"2017-01-30T17:16:02","modified_gmt":"2017-01-30T17:16:02","slug":"fill-dropdown-option-using-casperjs","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/","title":{"rendered":"How to Create Dropdown Attribute using Casperjs"},"content":{"rendered":"<p>In Magento there are various \u201crepetitive\u201d tasks to check such as create the attributes with multiple input type like Dropdown etc. These repetitive actions take a lot of time when we have done manually but now it can be done in few minutes by automation.<\/p>\n<p>Here we\u2019ll learn how we can select Dropdown option and fill the value of drop down option.<\/p>\n<p>Here we have used some CasperJs methods like-<\/p>\n<p><strong>click()<\/strong> method is used to click a link and buttons.<\/p>\n<p><strong>fill()<\/strong> method is used to fill the forms.<\/p>\n<p><strong>echo()<\/strong> is used to print.<\/p>\n<p><strong>wait() <\/strong>is used to wait for given amount of time.<\/p>\n<pre class=\"brush:js\">\/**\r\n* Webkul Software.\r\n*\r\n* @category Webkul\r\n* @package Webkul_CasperJS\r\n* @author Webkul\r\n* @copyright Copyright (c) 2010-2017 Webkul Software Private Limited (https:\/\/webkul.com)\r\n* @license https:\/\/store.webkul.com\/license.html\r\n*\/\r\nvar casper = require(\"casper\").create({\r\nverbose: true,\r\n});\r\n\r\nvar i;\r\ncasper.then(function(){\r\n    this.fill('form#edit_form', {\r\n       'frontend_input' : 'Country',  \/\/ 'name of the dropdown option' : 'Dropdown attribute title'\r\n    }, false);\r\n});\r\n\/\/ Add Dropdown options\r\nfor(i=1;i&lt;=3;i++)\r\n {\r\n  casper.then(function(){\r\n  this.click('#add_new_option_button');\r\n  });\r\n }\r\n\/\/ Enter the value of Dropdown options\r\ncasper.then(function(){\r\n    this.fill('form#edit_form', {          \/\/ fill dropdown values\r\n      'option[value][option_0][0]' : 'India',        \/\/ first value \/\/ Admin value\r\n      'option[value][option_1][0]' : 'United State',  \/\/ second value \/\/ Admin value\r\n      'option[value][option_2][0]' : 'China',        \/\/ third value \/\/ Admin value\r\n}, false);\r\n});\r\ncasper.then(function (){\r\n   this.echo('Form submitted..!!', \"PARAMETER\");\r\n   this.click('#save');\r\n});\r\ncasper.run();<\/pre>\n<div class=\"line number1 index0 alt2\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In Magento there are various \u201crepetitive\u201d tasks to check such as create the attributes with multiple input type like Dropdown etc. These repetitive actions take a lot of time when we have done manually but now it can be done in few minutes by automation. Here we\u2019ll learn how we can select Dropdown option and <a href=\"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":132,"featured_media":72298,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4313,8,302,211],"tags":[354,1908,2056,338,2070],"class_list":["post-72591","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-casperjs","category-magento","category-magento2","category-marketplace-2","tag-attribute","tag-dropdown","tag-magento","tag-magento-marketplace","tag-magento2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Create Dropdown Attribute using Casperjs - 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\/fill-dropdown-option-using-casperjs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create Dropdown Attribute using Casperjs - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"In Magento there are various \u201crepetitive\u201d tasks to check such as create the attributes with multiple input type like Dropdown etc. These repetitive actions take a lot of time when we have done manually but now it can be done in few minutes by automation. Here we\u2019ll learn how we can select Dropdown option and [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/\" \/>\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=\"2017-01-25T12:50:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-01-30T17:16:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/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=\"Nitin Kesarwani\" \/>\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=\"Nitin Kesarwani\" \/>\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\/fill-dropdown-option-using-casperjs\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/\"},\"author\":{\"name\":\"Nitin Kesarwani\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/fd4cbeb3f727008f603e02f59a06803d\"},\"headline\":\"How to Create Dropdown Attribute using Casperjs\",\"datePublished\":\"2017-01-25T12:50:34+00:00\",\"dateModified\":\"2017-01-30T17:16:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/\"},\"wordCount\":111,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/Code-Snippet.png\",\"keywords\":[\"Attribute\",\"dropdown\",\"magento\",\"magento marketplace\",\"Magento2\"],\"articleSection\":[\"CasperJS\",\"magento\",\"Magento2\",\"Marketplace\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/\",\"url\":\"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/\",\"name\":\"How to Create Dropdown Attribute using Casperjs - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/Code-Snippet.png\",\"datePublished\":\"2017-01-25T12:50:34+00:00\",\"dateModified\":\"2017-01-30T17:16:02+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/Code-Snippet.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/Code-Snippet.png\",\"width\":825,\"height\":260},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Create Dropdown Attribute using Casperjs\"}]},{\"@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\/fd4cbeb3f727008f603e02f59a06803d\",\"name\":\"Nitin Kesarwani\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/af0dd0ef20f3401b731cdd9df9900812e2272fef2a57c6c1123f2e2592ad7255?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\/af0dd0ef20f3401b731cdd9df9900812e2272fef2a57c6c1123f2e2592ad7255?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Nitin Kesarwani\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/nitin-kesarwani723webkul-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Create Dropdown Attribute using Casperjs - 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\/fill-dropdown-option-using-casperjs\/","og_locale":"en_US","og_type":"article","og_title":"How to Create Dropdown Attribute using Casperjs - Webkul Blog","og_description":"In Magento there are various \u201crepetitive\u201d tasks to check such as create the attributes with multiple input type like Dropdown etc. These repetitive actions take a lot of time when we have done manually but now it can be done in few minutes by automation. Here we\u2019ll learn how we can select Dropdown option and [...]","og_url":"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2017-01-25T12:50:34+00:00","article_modified_time":"2017-01-30T17:16:02+00:00","og_image":[{"width":825,"height":260,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/Code-Snippet.png","type":"image\/png"}],"author":"Nitin Kesarwani","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Nitin Kesarwani","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/"},"author":{"name":"Nitin Kesarwani","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/fd4cbeb3f727008f603e02f59a06803d"},"headline":"How to Create Dropdown Attribute using Casperjs","datePublished":"2017-01-25T12:50:34+00:00","dateModified":"2017-01-30T17:16:02+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/"},"wordCount":111,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/Code-Snippet.png","keywords":["Attribute","dropdown","magento","magento marketplace","Magento2"],"articleSection":["CasperJS","magento","Magento2","Marketplace"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/","url":"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/","name":"How to Create Dropdown Attribute using Casperjs - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/Code-Snippet.png","datePublished":"2017-01-25T12:50:34+00:00","dateModified":"2017-01-30T17:16:02+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/Code-Snippet.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/Code-Snippet.png","width":825,"height":260},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/fill-dropdown-option-using-casperjs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Create Dropdown Attribute using Casperjs"}]},{"@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\/fd4cbeb3f727008f603e02f59a06803d","name":"Nitin Kesarwani","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/af0dd0ef20f3401b731cdd9df9900812e2272fef2a57c6c1123f2e2592ad7255?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\/af0dd0ef20f3401b731cdd9df9900812e2272fef2a57c6c1123f2e2592ad7255?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Nitin Kesarwani"},"url":"https:\/\/webkul.com\/blog\/author\/nitin-kesarwani723webkul-com\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/72591","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\/132"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=72591"}],"version-history":[{"count":8,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/72591\/revisions"}],"predecessor-version":[{"id":73175,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/72591\/revisions\/73175"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media\/72298"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=72591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=72591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=72591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}