use strict; use warnings; use diagnostics; use lib '/home/rahul/Documents/'; use script::filldataforlocator qw(clickfield send_keys_field); use script::readxmlcid qw(get_child_node_value); use script::getdata qw(connectdatabase); use XML::LibXML; my $module_used_file = $ARGV[1]; open(my $module_build_file_handle, '<', $module_used_file)or die "Could not open file $module_used_file: $!"; my @module_file_lines = <$module_build_file_handle>; close $module_build_file_handle; my $dom = XML::LibXML->load_xml(location => $ARGV[0]); my $test_run_file_create = $dom->findvalue('//scenario/runname'); open(my $test_build_file_handle, '>', $test_run_file_create) or die "Could not open file '$test_run_file_create' $!"; foreach (@module_file_lines){ print $test_build_file_handle $_; } my @forms_required = ("createnewcid", "customerform"); my @child_node_values_fill; my $locatory_fields_id; my $locator_type; my $event_type; my $data_fill; my %hash_for_db_connect = ("companyname " => "contactnames", "contactname" => "contactnames", "title" => "contactnames"); foreach my $config_forms (@forms_required) { @child_node_values_fill = get_child_node_value($config_forms); foreach (@child_node_values_fill) { ($locatory_fields_id, $locator_type, $event_type, $data_fill) = split (/,/, $_); if (defined $locatory_fields_id && defined $locator_type && defined $event_type) { if ($event_type eq "click"){ print "My locator is $locatory_fields_id\n"; print $test_build_file_handle clickfield($locatory_fields_id, $locator_type)."\n"; print $test_build_file_handle "sleep(20)\;"."\n"; } elsif($event_type eq "send"){ if (defined $data_fill){ if (defined $hash_for_db_connect{$data_fill}){ my $input_field_value = connectdatabase("$data_fill", "smartcidtest.$hash_for_db_connect{$data_fill}"); print $test_build_file_handle send_keys_field($locatory_fields_id, $locator_type, "$input_field_value")."\n"; print $test_build_file_handle "sleep(20)\;"."\n"; } } } } } } close $test_build_file_handle; chmod 0755, $test_run_file_create;