Move an object in to view in a browser with UFT?
Question ID: 105755
1
0

I am trying to figure out how to move (scroll) browser so that an object is in view. Also, I noticed the visible attribute is not reliable.

Marked as spam
Posted by (Questions: 17, Answers: 5)
Asked on December 18, 2014 12:34 pm
1210 views
Answers (2)
1
Private answer

Here is what I found for getting object in view on a browser. This code might need to be expanded to check if MyObject exist and how to handle if does not exist.

'Go to object
Function pageGotoTop(ByRef myPage)
myjs=''window.scrollTo(0,0);''
myPage.RunScript(myjs)
wait .5
End Function

Function ObjGoto( myPage,MyObject)
' find object location
myY =MyObject.GetROProperty(''y'')
myX =MyObject.GetROProperty(''x'')
' Scroll to object location
myjs=''window.scrollTo('' & myX & '','' & myY & '');''
myPage.RunScript(myjs)
Wait .5
End Function

SET myPage=Browser(''MyBrowser'').Page(''myPage'')

'Scroll to top
pageGotoTop(myPage)

SET MyObject=Browser(''MyBrowser'').Page(''myPage'').Image(''TeamHub'')
ObjGoto myPage, MyObject

'Scroll to top
pageGotoTop(myPage)

SET MyObject=Browser(''MyBrowser'').Page(''myPage'').Link(''JavaFX and UFT'')
ObjGoto myPage, MyObject

Browser(''MyBrowser'').Page(''myPage'').Link(''JavaFX and UFT'').highlight

Marked as spam
Posted by (Questions: 2, Answers: 98)
Answered on December 18, 2014 12:36 pm
0
That works. I did not know you can inject js into browser.
( at December 18, 2014 12:41 pm)
0
Private answer

' Sroll an IE screen down until object is in view

Browser(''MyBrowser'').Page(''MyPage'').WebElement(''MyElement'').Object.scrollIntoView

Marked as spam
Posted by (Questions: 1, Answers: 1)
Answered on November 25, 2016 5:02 pm
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top