Sorry no timescales as yet.
But, yes, you can extend the ChromeDriver/EdgeDriver functions with standard HTTPRequest calls. Here are two functions. One which will get a list of windows and their internal names and another which can use one of these names to switch the browsing context:
Code: Select all
//returns a list of window names belonging to the current session
SRT>GetWindowHandles
HTTPRequest>http://localhost:9515/session/%GetWindowHandles_Var_1%/window/handles,,GET,,theResult
END>GetWindowHandles
//takes session ID and window name to switch browsing context to
SRT>SwitchWindow
Let>HTTP_POSTJSON=1
Let>body= { "name": "%SwitchWindow_Var_2%" }
//if you are not using the standard port and have changed it with CHROMEDRIVER_PORT then change the port number here accordingly
HTTPRequest>http://localhost:9515/session/%SwitchWindow_Var_1%/window,,POST,body,theResult
END>SwitchWindow
So, this works much like the built in function ChromeSwitchFrame.
Imagine you have a web page which opens another window when you click on a link. The following example will find the name of the new window and then switch browsing context to it, so that subsequent actions apply to that window instead of the first one:
Code: Select all
Let>CHROMEDRIVER_EXE=c:\drive_d\chromedriver.exe
ChromeStart>session_id
ChromeNavigate>session_id,url,https://www.blabla.com/somepage/test.html
GoSub>GetWindowHandles,session_id
//imagine we have a link with ID 'thelink' and clicking it produces a new window ...
ChromeFindElements>session_id,id,thelink,elements
ChromeElementAction>session_id,elements_1,click
Wait>2
//so now we can get a list of windows
GoSub>GetWindowHandles,session_id
//assuming we had only one window to start with so we'll get the second (index 1) item here. What you COULD do if you didn't know how many you had is call GetWindowHandles BEFORE clicking the link, then compare and use the new handle which didn't exist previously ...
JSONParse>theResult,$.value[1],newHandle
//now switch browsing context
GoSub>SwitchWindow,session_id,newHandle_1
//now the Chrome functions will find/act on elements inside the NEW window. Remember to switch context back later if needed ....
ChromeFindElements>session_id,tag name,a,allAs
SRT>GetWindowHandles
HTTPRequest>http://localhost:9515/session/%GetWindowHandles_Var_1%/window/handles,,GET,,theResult
END>GetWindowHandles
//takes session ID and window name to switch browsing context to
SRT>SwitchWindow
Let>HTTP_POSTJSON=1
Let>body= { "name": "%SwitchWindow_Var_2%" }
//if you are not using the standard port and have changed it with CHROMEDRIVER_PORT then change the port number here accordingly
HTTPRequest>http://localhost:9515/session/%SwitchWindow_Var_1%/window,,POST,body,theResult
END>SwitchWindow
Hope this helps.