我有一個表格,我填寫了一些資料,一切正常,直到我嘗試點擊提交按鈕。它根本沒有回應這是元素的 outHTML
<input type="submit" class="btn btn-primary commandButton" value="????? ???????" id="cmdSubmit">
我試過這些線
.ExecuteScript "arguments[0].click();", .FindElementByCss("#cmdSubmit")
我什至嘗試了 byID 和 byXPATH 并且沒有使用該元素
在檢查網頁時,我搜索了提交,我想我找到了相關的功能
<script>
$('#frmExecReq').submit(function(){ // catch form submit event
if($('#selectAsed').val() <= 0){
$('#selectAsedWarninig').show();
return false;
}
if(!$.isNumeric($('#phoneNo').val())){
$('#phoneNoWarninig').show();
return false;
}
var mobileNumber = document.getElementById("phoneNo").value;
var mobileLength = mobileNumber.length;
var checkFirstNumber = mobileNumber.substring(0, 1);
if(mobileNumber ==""){
document.getElementById('phoneNoWarninig').style.display = 'inline';
document.getElementById('phoneNo').focus();
document.getElementById('phoneNo').select();
return false;
}else if( mobileLength !=8 ){
document.getElementById('phoneNoWarninig').style.display = 'inline';
document.getElementById('phoneNo').focus();
document.getElementById('phoneNo').select();
return false;
}else if(checkFirstNumber != 5 && checkFirstNumber != 6 && checkFirstNumber != 9){
document.getElementById('phoneNoWarninig').style.display = 'inline';
document.getElementById('phoneNo').focus();
document.getElementById('phoneNo').select();
return false;
}
if($('#txtReceivedSum').length){
if(!$.isNumeric($('#txtReceivedSum').val())){
$('#txtReceivedSumWarninig').show();
return false;
}
}
//////////
var trnCodeNum = document.getElementById("trnCodeNum").value;
var persType = document.getElementById("persType").value;
if( (trnCodeNum == 0815 && persType == 2) || (trnCodeNum == 0875 && persType == 2) || (trnCodeNum == 0820 && persType == 1)
|| trnCodeNum == 0810 || trnCodeNum == 0825){
var y = document.getElementById('attachments');
if ('files' in y) {
if (y.files.length == 0) {
document.getElementById('reqWarning2-1').style.display = 'inline';
//$('#sreqFile1Warning1').show();
return false;
} else {
var file = y.files[0];
if ('name' in file) {
var n = file.name;
fileExtension = n.split('.').pop();
if (!(fileExtension == "pdf")) {
$('#reqWarning2-2').show();
return false;
}
if ('size' in file) {
if (file.size > 10485762) { //10 MB
$('#reqWarning2-3').show();
return false;
}
}
}
}
}
}
///////////
var form = $('#frmExecReq')[0];
// Create an FormData object
var data = new FormData(form)
$.ajax({ // create ajax call
data: data, //get form data
//contentType: 'multipart/form-data',
processData: false,
contentType: false,
method: 'POST',
type: $(this).attr('method'), //GET or POST
url: $(this).attr('action'), // the action url
success: function(response){ // on success
$('#viewPaneChildDetails').html(response); //update DIV
$('#viewPaneChild').hide();
$('#viewPaneChildDetails').show();
}
});
return false; // cancel original event to prevent form submitting
});
</script>
嘗試此行時,發生錯誤
.FindElementByXPath("//input[@class='btn btn-primary commandButton' and @id=='dSubmit'][@vlaue='????? ???????']").Click

uj5u.com熱心網友回復:
要單擊元素,您可以使用以下任一定位器策略:
使用FindElementByCss:
.FindElementByCss("input.btn.btn-primary.commandButton#cmdSubmit").click使用FindElementByXPath:
.FindElementByXPath("//input[@class='btn btn-primary commandButton' and @id='cmdSubmit']").click
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/458950.html
上一篇:按標題而不是excel字母搜索列
