Function QTP-调用身份验证时函数不起作用

Function QTP-调用身份验证时函数不起作用,function,qtp,Function,Qtp,下面是要调用以获取用户名和密码的函数: Function SetWebEdit(TempObj,Value) Err.Clear On Error Resume Next If Value="" Then Exit Function TempObj.Set Value If Err.Number<>0 Then strName=Split(Err.Description,Chr(34)) If UBound(s

下面是要调用以获取用户名和密码的函数:

 Function SetWebEdit(TempObj,Value)
 Err.Clear
 On Error Resume Next

 If Value="" Then Exit Function 
 TempObj.Set Value              
 If Err.Number<>0 Then
    strName=Split(Err.Description,Chr(34))       
    If UBound(strName)=0 Then
        strMsg=strName(0)
    Else
        StrMsg=strName(1)
    End If
    strDesc=Err.Description
除了以下一个特定时间外,它工作正常:

单击“授权”按钮,但不输入用户名和密码。请让我知道问题和可能的解决方案


谢谢大家!

假设您的所有函数和ID(您已从上面粘贴的代码中隐藏)都工作正常,代码中似乎没有任何问题。你能不能在调试模式下设置一个断点并运行它,让我们知道错误在哪一行,QTP显示了什么错误,没有它只是一个猜测游戏。谢谢你的回复。运行代码时没有错误,手动执行时应用程序将移动到下一页。即使我在函数本身中给出用户名和密码的代码,它也不会转到下一页。我将在调试模式下运行并查看结果。您是否登录页面两次??因为根据您的代码,当“授权”按钮存在时,您只需登录一次,然后在调用Authenticate()函数时,再次尝试提供用户名和密码。(很抱歉,在您的评论说它没有给出错误后,再次正确地检查了您的代码,可能是因为在您调用Authenticate()时它无法再次找到用户名和密码对象。我不确定这是否是错误,但可能是,请检查并让我知道)不。。我已经修改了我最新使用的代码。而且,如果对象没有被识别,那么对于前面的场景也应该是相同的。但在其他情况下,它会在文本框中输入值。只有这种情况不起作用。是否有关于脚本如何在调试模式下运行的更新?在更新的代码中,我找不到用户名、密码和登录对象的设置。此外,您的“授权”按钮不会在任何地方被单击
Function Authenticate()

'Set the username and password and click on Sign in
 Set Global_Authentication=obj_homepage.WebElement("objectid")
'Global_Authentication.highlight
if Global_Authentication.Exist(10) then
Call SetWebEdit(Username,"name")
Encryped_Pwd="12345"
Password.SetSecure Encryped_Pwd
wait(2)
Call ClickWebButton(Signin)
wait(5)
End if
End Function
Function Check_Out()

'Set Resolve_click = obj_homepage.WebElement("objectid")
Set Resolve_click = obj_homepage.WebElement("objectid")
IF Resolve_click.Exist(10) then
Call ClickWebElement(Resolve_click)
End IF
wait(5)

Set Authorize_button = obj_homepage.WebButton("objectid")
If Authorize_button.Exist(10) Then
Call ClickWebButton(Authorize_button)

End if
    wait(10)

    Call Authenticate()

    wait(15)
    Set Paper_Form_Signed = obj_homepage.WebButton("objectid")
    If Paper_Form_Signed.Exist(10) Then
    Call ClickWebButton(Paper_Form_Signed)
    End if 
    wait(8)
End Function