Those ones can be quite fiddly. You have to switch context, interact, then switch it back again. You can see the original explanation
here.
This does what you require :
Code: Select all
let>TheURL=https://www.youtube.com/
Let>CHROMEDRIVER_EXE=c:\chromedriver.exe
ChromeStart>session_id
put>session_id
ChromeNavigate>session_id,url,%TheURL%
//Get current Windows
GoSub>GetWindowHandles,session_id
//Wait to ensure window has popped up (may need to increase this)
wait>1
//Get a list of windows
GoSub>GetWindowHandles,session_id
JSONParse>theResult,$.value[1],newHandle
JSONParse>theResult,$.value[0],mainHandle
//Now switch browsing context
GoSub>SwitchWindow,session_id,newHandle_1
//Click the button
ChromeFindElements>session_id,xpath,//yt-formatted-string[@class='style-scope ytd-button-renderer style-primary size-default'],el
ChromeElementAction>session_id,el_2,click
//Switch back to main window
GoSub>SwitchWindow,session_id,mainHandle_1
//
//continue script
//
//Subroutines
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