对象不支持此属性或方法document.getElementById()。Value

时间:2014-10-10 01:24:48

标签: vbscript

我正在尝试运行VBS,但一直收到错误。

对象不支持此属性或方法document.getElementById()。Value 尝试将我的IE设置重置为默认值并使用其他版本的IE仍然面临同样的问题

以下是脚本详细信息

strAssets = "Assets.txt"
strOutput = "AssetWarranties.csv"
strSite = "https://selfsolve.apple.com/agreementWarrantyDynamic.do"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForReading = 1
Set objInput = objFSO.OpenTextFile(strAssets, intForReading, False)
Set objOutput = objFSO.CreateTextFile(strOutput, True)
objOutput.WriteLine """Serial"",""Status"",""Telephone Support"",""Expiry"",""Hardware Support"",""Expiry"""

While Not objInput.AtEndOfStream
	strImei = Trim(objInput.ReadLine)
	If strImei <> "" Then
		Set objFF = CreateObject("InternetExplorer.Application")
		objFF.Visible = True
		objFF.Navigate strSite
		While objFF.ReadyState <> 4 Or objFF.Busy
			WScript.Sleep 100
		Wend
		objFF.document.getElementById("serialnumbercheck"). Value = strImei
		objFF.document.getElementById("warrantycheckbutton"). Click()
		While InStr(objFF.Document.body.InnerHTML, "<H3 id=registration-true>") = 0 And _
			InStr(objFF.Document.body.InnerHTML, "<H3 id=registration-false>") = 0 And _
			InStr(objFF.Document.body.InnerHTML, "serial number is not valid") = 0
			WScript.Sleep 100
		Wend
		
		strPageText = objFF.Document.body.InnerHTML
		objFF.Quit
		
		If InStr(strPageText, "serial number is not valid") > 0 Then
			'WScript.Echo "Serial number is not valid"
			objOutput.WriteLine """" & strImei & """,""Serial number is not valid"""
		Else
			strDetail = """" & strImei & """"
			If InStr(strPageText, "<H3 id=registration-true>") > 0 Then
				'WScript.Echo "Valid Purchase Date"
				strDetail = strDetail & ",""Valid Purchase Date"""
			Else
				'WScript.Echo "Purchase Date not Validated"
				strDetail = strDetail & ",""Purchase Date not Validated"""
			End If
			If InStr(strPageText, "<H3 id=phone-true>") > 0 Then
				'WScript.Echo "Telephone Technical Support: Active"
				strDetail = strDetail & ",""Telephone Technical Support: Active"""
				intPos = InStr(InStr(strPageText, "<H3 id=phone-true>"), strPageText, "Estimated Expiration Date: ")
				If intPos > 0 Then
					strExpiration = Mid(strPageText, intPos, InStr(intPos, strPageText, "</P>") - intPos)
					'WScript.Echo strExpiration
					strDetail = strDetail & ",""" & strExpiration & """"
				Else
					'WScript.Echo "Estimated Expiration Date: UNKNOWN"
					strDetail = strDetail & ",""Estimated Expiration Date: UNKNOWN"""
				End If
			Else
				'WScript.Echo "Telephone Technical Support: Expired"
				strDetail = strDetail & ",""Telephone Technical Support: Expired"""
			End If
			If InStr(strPageText, "<H3 id=hardware-true>") > 0 Then
				'WScript.Echo "Repairs and Service Coverage: Active"
				strDetail = strDetail & ",""Repairs and Service Coverage: Active"""
				intPos = InStr(InStr(strPageText, "<H3 id=hardware-true>"), strPageText, "Estimated Expiration Date: ")
				If intPos > 0 Then
					strExpiration = Mid(strPageText, intPos, InStr(intPos, strPageText, "<BR>") - intPos)
					'WScript.Echo strExpiration
					strDetail = strDetail & ",""" & strExpiration & """"
				Else
					'WScript.Echo "Estimated Expiration Date: UNKNOWN"
					strDetail = strDetail & ",""Estimated Expiration Date: UNKNOWN"""
				End If
			Else
				'WScript.Echo "Repairs and Service Coverage: Not Active"
				strDetail = strDetail & ",""Repairs and Service Coverage: Not Active"""
			End If
			objOutput.WriteLine strDetail
		End If
	End If
Wend
objInput.Close
objOutput.Close
WScript.Echo "Done"

2 个答案:

答案 0 :(得分:0)

你应该试试

objFF.document.getElementById("sn"). Value = strImei

因为serialnumbercheck<form>的名称,而不是输入字段

答案 1 :(得分:0)

使用&gt;&gt; objFF.document.getElementById(“sn”)。value = strImei

insted of“objFF.document.getElementById(”serialnumbercheck“)。Value = strImei”