Skip to main content

Set-Webpage-Cookies

Command Description

Set the Cookies data of the webpage

Command Prototype

WebBrowser.SetCookies(hWeb,dictCookies,optionArgs)

Parameter Description

ParameterRequiredTypeDefaultDescription
hWebTrueexpressionhWebBrowser handle string using WebBrowser.create or WebBrowser.bind Command Returns
dictCookiesTrueexpression{}One or many Cookie names are paired with Cookie values, building JSON objects
bContinueOnErrorNonebooleanNoneSpecify whether the automation should continue to support this field even if the activity is incorrect, it is only supported by the Boolean value (true, false) default value
iDelayAfterNonenumber300Delay time (in milliseconds) after executing the activity is 300 milliseconds
iDelayBeforeNonenumber200The delay time (in milliseconds) before any operations are executed is by default 200 milliseconds

Demo

/************************************Set Cookies**************** ************************ 
Command prototype:
WebBrowser.SetCookies(hWeb,dictCookies,optionArgs)
Input parameters:
hWeb--Browser object
dictCookies--a JSON object composed of one or more Cookie names and Cookie values ​​paired
bContinueOnError--whether to continue after error
iDelayAfter-- delay after execution
iDelayBefore--delay before execution
*********************************************************************************/
Dim hWeb,iRet,vCookies
hWeb = WebBrowser.Create("ie","www.baidu.com",30000,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200,"sBrowserPath":"","sStartArgs":""})
TracePrint(hWeb)
iRet = WebBrowser.GoURL(hWeb,"https://laiye.com/download?source=product-process-creator-banner",false,{},30000,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})
vCookies = WebBrowser.GetCookies(hWeb,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})
WebBrowser.SetCookies(hWeb, vCookies ,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})