clicking on particular link using qtp function

2019-03-06 15:39发布

I want to automate login process to flipkart by creating a function which is being called in an action

Function Website() 'this is the function
Systemutil.Run("iexplore.exe"), "http://www.flipkart.com" 
End Function

Website() 'this is where the function is called in the action

The browser is opening but I don't know how to click on login without doing a record and run , but only through code and the function.

Please help me.

2条回答
够拽才男人
2楼-- · 2019-03-06 16:32

If you want to do it with descriptive programming, this would be a simple example: (I used the direct login-page, because it is easier than clicking on that login link)

Website()

Function Website()
    Systemutil.Run("iexplore.exe"), "https://www.flipkart.com/account/login?from=header"
    set objPage = Browser("title:=Flipkart.com: Login.*").Page("title:=Flipkart.com: Login.*")

    objPage.Sync()

    objPage.WebEdit("html id:=login_email_id1").Set "UsernameXY"
    objPage.WebEdit("html id:=login_password1").Set "SecretPassword"
    objPage.WebButton("html id:=login-cta").Click()

End Function
查看更多
一纸荒年 Trace。
3楼-- · 2019-03-06 16:35

You can choose two approaches from here. 1. Object Repository: Press Ctrl + R to Open object repository. Then add objects to your repository. Once you add them, Just Drag and drop.

  1. Descriptive Programming: Just Like answer one
查看更多
登录 后发表回答