Добры день, Уважаемые!
Есть Web форма, через нее импортируются данные в систему.
Если делаю это руками-мышкой - все работает, если через автоматизацию возникают ошибки доступа и данные не грузятся
грузим данные примерно так
Сам PopUpFiller
результат
Тыканье в ручную по тому же маршруту - работает... :-\
Есть Web форма, через нее импортируются данные в систему.
Если делаю это руками-мышкой - все работает, если через автоматизацию возникают ошибки доступа и данные не грузятся
Код:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.aaa.org/TR/html4/loose.dtd">
<html>
<head>
<title>Batch Import Create Ticket</title>
<script>
var locale='en_US';
var include='validate,prompt,mask';
var tabInit='true';
var isPageIntegration = false;
</script>
<script type="text/javascript" src="/taskClient/style/libs/jquery/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/taskClient/style/simple2/js/first.js"></script>
<link rel="stylesheet" type="text/css" href="/taskClient/style/simple2/css/tab.css" />
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="/taskClient/style/simple2/css/ie6.css" />
<![endif]-->
<style>
#uploadSpan{ font-size:12px; overflow:hidden; position:absolute}
#attachment{ position:absolute; z-index:100; margin-left:-180px; font-size:60px;opacity:0;filter:alpha(opacity=0); margin-top:-5px;}
</style>
<script type="text/javascript"><!--
var contentPath = "/taskClient";
var username = "importer";
Nf.loadResource("search2/taskprocess/common/ticketimport/BatchImportResult");
function submitExcel()
{
var excelFile = $("#attachment").val();
if(excelFile == '')
{
Nf.promptError({
message:Nf.res("sdm.si.ticketImport.import.withoutSelect")
});
return false;
}
saveUser();
}
function saveUser() {
var myMask = new Nf.LoadMask('importBody', {
msg : Nf.res("sdm.si.ticketImport.import.load")
});
myMask.show();
console.log("request begin...");
Ext.Ajax.request({
url: contentPath+"/taskprocess/ticketsImport.action",
method: "POST",
isUpload :true,
form: batchCreateTicket,
dataType:"json",
success: function (response) {
myMask.hide();
eval("resultMessage="+response.responseText);
if(null != resultMessage.importReturnMsg){
Nf.promptAlert({
message:Nf.res(resultMessage.importReturnMsg)
});
}
if(resultMessage.importMessage){
Nf.promptAlert({
message:Nf.res(resultMessage.importMessage)
});
}
document.batchCreateTicket.reset();
}
,
failure: function ()
{
myMask.hide();
Ext.Msg.alert("提示", "导入结果错误");
}
});
}
function showNotice()
{
Nf.promptAlert({
message : Nf.res("sdm.si.ticketImport.import.page.showNotice"),
handler : function(btn){}, height : 150, width : 250
});
}
function doDownLoad(ticketType)
{
$("#ticketType").val(ticketType);
var excelForm = $("#excelFile");
excelForm.submit();
}
function watchResult()
{
window.location.href = contentPath
+ "/taskprocess/batchImportResult.action?username="
+ username;
}
function setTextValue()
{
var textValue = $("#attachment").val();
if(textValue != '')
{
var value = textValue.substring(textValue.lastIndexOf(".")+1, textValue.length);
if ("xls" == value || "xlsx" == value)
{
$("#filePath").val(textValue);
if("xlsx" == value)
{
$("#importExcelType").val("2007");
}
else
{
$("#importExcelType").val("2003");
}
}
else
{
Nf.promptError({
message:Nf.res("sdm.si.ticketImport.import.formatError")
});
$("#filePath").val("");
$("#attachment").val("");
}
}
}
// 去除属性,以免不同分辨率的浏览器出现滚动条,导致页面上传按钮偏移
Nf.ready(function()
{
var body = document.getElementById("importBody");
body.style.overflow = "visible";
});
--></script>
</head>
<body id="importBody">
<!--
<div nfType="Nf.form.PageInfo">
You can batch import ticket here!
</div>
-->
<form name="excelFile" id="excelFile" method="post"
action="/taskClient/taskprocess/downloadTemplate.action">
<input type="hidden" id="username" name="username" value="importer">
<input type="hidden" id="ticketType" name="ticketType" value="">
<table border="0" align="center" cellpadding="0"
cellspacing="0" class="list_table">
<tr>
<td style="padding-left: 5px;" class="td_table_1">
<b>projectName:PROJECT</b>
</td>
</tr>
<tr>
<td style="padding-left: 5px;" class="td_table_1">
<b>Export Excel Template</b>
</td>
</tr>
</table>
<table border="0" align="center" cellpadding="0"
cellspacing="0" class="list_table">
<tr>
<td style="padding-left: 5px;" class="td_table_1" width="20px">
<b>Notice</b>
</td>
<td>
1.Please don't modify any column name or sheet name of the template file.
2.Order information fields which start with "*" can't be left blank.
</td>
</tr>
<tr>
<td style="padding-left: 5px;" class="td_table_1">
<b>Excel Type</b>
</td>
<td class="td_table_2" >
<input type="radio" id="excelType" name="excelType" value="2003" checked="checked" />Excel 2003
<input type="radio" name="excelType" value="2007" />Excel 2007
</td>
</tr>
<tr>
<td style="padding-left: 5px;" class="td_table_1">
<b>Ticket Type</b>
</td>
<td class="td_table_2" colspan="1">
<div>
<a href="#" onclick="doDownLoad('CM')" >
Corrective Maintenance</a>
<a href="#" onclick="doDownLoad('PM')" >
Preventive Maintenance</a>
<a href="#" onclick="doDownLoad('PLM')" >
Planned Maintenance</a>
<a href="#" onclick="doDownLoad('Others')" >
Others</a>
</div>
</td>
</tr>
</table>
</form>
<form name="batchCreateTicket" id="batchCreateTicket"
action="/taskClient/taskprocess/ticketsImport.action"
enctype="MULTIPART/FORM-DATA" method="post">
<input type="hidden" name="username" value="importer">
<input type="hidden" id="importExcelType" name="excelType" value="">
<table border="0" align="center" cellpadding="0"
cellspacing="0" class="list_table">
<tr>
<td style="padding-left: 5px;" class="td_table_1">
<b>Import Excel Template</b>
</td>
</tr>
</table>
<table border="0" align="center" cellpadding="0"
cellspacing="0" class="list_table">
<tr>
<td class="td_table_1" align="right">
<b>Import File</b>
</td>
<td class="td_table_2" colspan="1">
<input type="text" name="filePath" id="filePath" readonly="readonly" style="margin-left: 5px; left: 0px; top: 2px; width: 320px; height: 18px;" />
<label class="required" style="color: red;">*</label>
<span id="uploadSpan">
<input type="file" id="attachment" name="attachment" size="1" onchange="setTextValue()" />
<input type="button" class="button20" value="Browse..." >
</span>
</td>
</tr>
<tr>
<td class="td_table_1" align="right">
<b>Operation</b>
</td>
<td class="td_table_2" colspan="1">
<input type="button" class="button20" id="save" name="save"
value="Import" onclick="submitExcel()" />
<input type="button" class="button20" id="seeRsult" name="result"
value="Watch Import Result" onclick="watchResult()" />
</td>
</tr>
</table>
</form>
</body>
</html>
<!--<script type="text/javascript">
function importTicket(){
var myMask = new Nf.LoadMask('batchCreateTicket', {msg : 'loading...'});
myMask.show();
}
</script>
--><!-- 错误信息弹框 --start -->
<!-- 错误信息弹框 --end -->
<script type="text/javascript">
var titlename='Batch Import Create Ticket';
var projectName ="PROJECT";
Nf.ready(function () {
if(isPageIntegration)
{
crossDomainSetCurrentTabTitle(titlename);
}
});
</script>
грузим данные примерно так
Код:
Run(@ScriptDir&"\PopUpFiller.exe")
sleep(1000)
$oIE.document.parentWindow.execScript("setTimeout(function(){document.getElementById('attachment').click()},0)")
sleep(2000)
$oIE.document.parentWindow.execScript("setTimeout(function(){document.getElementById('save').click()},0)")
Сам PopUpFiller
Код:
Local $hWnd = WinWait("Choose File to Upload", "", 0)
Sleep(500)
ControlSend($hWnd, "", "Edit1", "uplCM1.xls")
Sleep(300)
ControlClick($hWnd, "", "[CLASSNN:Button1]")
результат