Hi SaranKumar,
Please find below code for Click_webElement in Portal ,I used same function for my SAP portal project...............
Please find below code for Click_webElement in Portal ,I used same function for my SAP portal project...............
Code:
Public Function fn_Portal_ClickWebElement_Page(strPageTitle,strWebElementHtmlId_InnerText)
'*Variable Declarations
Dim objBrowser,objPage,objAllBrowser,objPortal,objWebElement
'*Browser Object
Set objBrowser = Description.Create
objBrowser("micclass").Value = "Browser"
'*Get all browsers object
Set objAllBrowser = Desktop.ChildObjects(objBrowser)
'*Page Object
Set objPage = Description.Create
objPage("micclass").Value = "Page"
objPage("title").Value = strPageTitle
'*Portal Object
Set objPortal = Description.Create
objPortal("micclass").Value = "SAPPortal"
'*Web Element Object
Set objWebElement = Description.Create
objWebElement("micclass").Value = "WebElement"
objWebElement("html id").Value = strWebElementHtmlId_InnerText
'*Look for the web element and click if it exists
If Browser("creationtime:=" & objAllBrowser.Count - 1).Page(objPage).Exist(0) Then
If Browser("creationtime:=" & objAllBrowser.Count - 1).Page(objPage).WebElement(objWebElement).Exist(0) Then
Browser("creationtime:=" & objAllBrowser.Count - 1).Page(objPage).WebElement(objWebElement).click
fn_Portal_ClickWebElement_Page=true
Else
'*Web Element Object
Set objWebElement = Description.Create
objWebElement("micclass").Value = "WebElement"
objWebElement("innertext").Value = strWebElementHtmlId_InnerText
If Browser("creationtime:=" & objAllBrowser.Count - 1).Page(objPage).WebElement(objWebElement).Exist(0) Then
Browser("creationtime:=" & objAllBrowser.Count - 1).Page(objPage).WebElement(objWebElement).click
fn_Portal_ClickWebElement_Page=true
Else
fn_Portal_ClickWebElement_Page=false
End if
End if
ElseIf Browser("creationtime:=" & objAllBrowser.Count - 1).SAPPortal(objPortal).Exist(0) Then
If Browser("creationtime:=" & objAllBrowser.Count - 1).SAPPortal(objPortal).WebElement(objWebElement).Exist(0) Then
Browser("creationtime:=" & objAllBrowser.Count - 1).SAPPortal(objPortal).WebElement(objWebElement).click
fn_Portal_ClickWebElement_Page=true
Else
'*Web Element Object
Set objWebElement = Description.Create
objWebElement("micclass").Value = "WebElement"
objWebElement("innertext").Value = strWebElementHtmlId_InnerText
If Browser("creationtime:=" & objAllBrowser.Count - 1).SAPPortal(objPortal).WebElement(objWebElement).Exist(0) Then
Browser("creationtime:=" & objAllBrowser.Count - 1).SAPPortal(objPortal).WebElement(objWebElement).click
fn_Portal_ClickWebElement_Page=true
Else
fn_Portal_ClickWebElement_Page=false
End if
End if
Else
fn_Portal_ClickWebElement_Page=false
End if
'*Releasing variables
Set objBrowser=Nothing
Set objPage=Nothing
Set objAllBrowser=Nothing
Set objPortal=Nothing
Set objWebElement=Nothing
End Function