ranphx 0 Posted May 11 Share Posted May 11 Hello, I have the following problem I need to write a script that opens different sites in the tabbar of Chrome, scrolls down each site and switches everytime, it reached the bottom of a page. So far I managed it to open the sites and switch between them but my script right now is just depending on a specific time to switch which is unfortunate because the sites are not the same length So there is a difference in the waiting time between the sites while it still tries to scroll down. Because I'm new to autoit I don't know for sure if there is a function that could tell me if Chrome reached the bottom of a site like I found with getScrollPos in C++ . Link to post Share on other sites
Developers Jos 2,685 Posted May 11 Developers Share Posted May 11 Moved to the appropriate AutoIt General Help and Support forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to post Share on other sites
Nine 1,521 Posted May 11 Share Posted May 11 One way would be to use WebDriver and execute JavaScript to get the height of the document and compare it with the position of the scroll bar (or something similar) . That seems to work quite well : Local $JS_ScrollTop = Json_Decode(_WD_ExecuteScript($sSession, 'return document.documentElement.scrollTop;')) Local $JS_Scr_Height = Json_Decode(_WD_ExecuteScript($sSession, "return screen.height;")) Local $JS_Doc_Height = Json_Decode(_WD_ExecuteScript($sSession, "return document.body.scrollHeight;")) Local $JS_Scr_InnerHeight = Json_Decode(_WD_ExecuteScript($sSession, "return window.innerHeight;")) ConsoleWrite("ScrollTop " & Json_Get($JS_ScrollTop, "[value]") & @CRLF & _ "Scr_Height " & Json_Get($JS_Scr_Height, "[value]") & @CRLF & _ "Doc_Height " & Json_Get($JS_Doc_Height, "[value]") & @CRLF & _ "Scr_InnerHeight " & Json_Get($JS_Scr_InnerHeight, "[value]") & @CRLF) Local $iScrollTop = Number(Json_Get($JS_ScrollTop, "[value]")) Local $iDocHeight = Number(Json_Get($JS_Doc_Height, "[value]")) Local $iInnerHeight = Number(Json_Get($JS_Scr_InnerHeight, "[value]")) If $iScrollTop + $iInnerHeight >= $iDocHeight Then MsgBox($MB_SYSTEMMODAL, "You are", "at the bottom") Not much of a signature but working on it... Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search content in au3 files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector GIF Animation (cached) Screen Scraping Link to post Share on other sites
Danp2 1,277 Posted May 11 Share Posted May 11 @NineYou could use an array to eliminate the repeated calls to _WD_ExecuteScript -- $sScript = "return new Array(document.documentElement.scrollTop, screen.height, document.body.scrollHeight, window.innerHeight);" $aResults = _WD_ExecuteScript($sSession, $sScript, $_WD_EmptyDict, Default, $_WD_JSON_Value) I'm wondering if this could be done with one of the _GuiScrollBars functions. mLipok 1 WebDriver UDF [GH&S] Latest version Wiki FAQs Link to post Share on other sites
Nine 1,521 Posted May 11 Share Posted May 11 30 minutes ago, Danp2 said: I'm wondering if this could be done with one of the _GuiScrollBars functions. I tried it but it doesn't work. I do believe that the scroll bars are not standard Window elements (like pretty much everything else in Chrome). 33 minutes ago, Danp2 said: You could use an array to eliminate the repeated calls Thanks for the tip. As you can see, I am not a JS wizard... Danp2 1 Not much of a signature but working on it... Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search content in au3 files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector GIF Animation (cached) Screen Scraping Link to post Share on other sites
ranphx 0 Posted May 18 Author Share Posted May 18 Is there an option without WebDriver, cause I need it for work but they seem to be hesitant to let me install it. Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now