How can I scroll down a browser page in IE11 and UFT?
Question ID: 105756
1
0

How can I scroll down a browser page. I am trying to scroll down a IE 11 browser page down with following code that worked before


	Set objBase = Browser("micClass:=Browser").Page("micClass:=Page")
	objBase.Object.body.doScroll("pageDown")

But is now working.

Marked as spam
Posted by (Questions: 44, Answers: 0)
Asked on December 18, 2014 12:44 pm
1999 views
Answers (1)
1
Private answer

Microsoft has change the way things are done with IE 11. They [no longer support VBScript in IE 11][1]. Also Microsoft has [obsoleted several objects and methods in IE 11 ][2]. One of the object is the body.

There couple ways that a page up or down (scroll) can be sent to Internet Explorer.
1. Low Level recording.
2. Dynamic find the Browsers windows handle and use Mercury DeviceReplay.
3. Inject javascript into the page.

Below are examples of each. I prefer to use option #3.

'-----------------------------------------------------------------------
Browser(''msn'').Page(''msn'').Sync
Browser(''msn'').Navigate ''http://eyeontesting.com/''
'-----------------------------------------------------------------------
'Low level

Window(''Internet Explorer'').Activate
Window(''Internet Explorer'').WinObject(''Internet Explorer_Server'').Type micPgDwn
wait 2
Window(''Internet Explorer'').WinObject(''Internet Explorer_Server'').Type micPgUp
wait 2
Window(''Internet Explorer'').WinObject(''Internet Explorer_Server'').Type micEnd
wait 2
Window(''Internet Explorer'').WinObject(''Internet Explorer_Server'').Type micHome
wait 2
'-----------------------------------------------------------------------
''Device replay option
myhWnd=Browser(''msn'').Object.HWND
Set myWindow = Window(''HWND:='' & myhWnd)
'
myWindow.Activate

Set devicereplay = CreateObject(''Mercury.DeviceReplay'')
devicereplay.PressKey 209 'page down
wait 2
devicereplay.PressKey 201 'page up
wait 2
devicereplay.PressKey 207 'End
wait 2
devicereplay.PressKey 199 'Home

Set devicereplay = Nothing
set obj = nothing
'-----------------------------------------------------------------------
' Run script method
Browser(''msn'').Page(''msn'').Sync

'Scroll the document by 100px vertically:
myjs=''window.scrollBy(0, 100);''
Browser(''msn'').Page(''msn'').RunScript(myjs)
wait 2

'Scroll the document to position ''300'' horizontally and ''500'' vertically:
myjs=''window.scrollTo(300, 500);''
Browser(''msn'').Page(''msn'').RunScript(myjs)
wait 2

'Scroll to top
myjs=''window.scrollTo(0,0);''
Browser(''msn'').Page(''msn'').RunScript(myjs)
wait 2

'scroll to bottom
myjs=''window.scrollTo(0, document.body.scrollHeight);''
Browser(''msn'').Page(''msn'').RunScript(myjs)
wait 2

[1]: http://msdn.microsoft.com/en-us/library/ie/dn384057%28v=vs.85%29.aspx
[2]: http://msdn.microsoft.com/en-us/library/windows/apps/Hh700404.aspx

Marked as spam
Posted by (Questions: 2, Answers: 98)
Answered on December 18, 2014 12:50 pm
0
Thank you for all the options.
( at December 18, 2014 12:51 pm)
EyeOnTesting

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

X
Scroll to Top