In Magento there are various “repetitive” 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’ll learn how we can select Dropdown option and fill the value of drop down option.
Here we have used some CasperJs methods like-
click() method is used to click a link and buttons.
fill() method is used to fill the forms.
echo() is used to print.
wait() is used to wait for given amount of time.
/** * Webkul Software. * * @category Webkul * @package Webkul_CasperJS * @author Webkul * @copyright Copyright (c) 2010-2017 Webkul Software Private Limited (https://webkul.com) * @license https://store.webkul.com/license.html */ var casper = require("casper").create({ verbose: true, }); var i; casper.then(function(){ this.fill('form#edit_form', { 'frontend_input' : 'Country', // 'name of the dropdown option' : 'Dropdown attribute title' }, false); }); // Add Dropdown options for(i=1;i<=3;i++) { casper.then(function(){ this.click('#add_new_option_button'); }); } // Enter the value of Dropdown options casper.then(function(){ this.fill('form#edit_form', { // fill dropdown values 'option[value][option_0][0]' : 'India', // first value // Admin value 'option[value][option_1][0]' : 'United State', // second value // Admin value 'option[value][option_2][0]' : 'China', // third value // Admin value }, false); }); casper.then(function (){ this.echo('Form submitted..!!', "PARAMETER"); this.click('#save'); }); casper.run();
Be the first to comment.