#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.16.1 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here ; #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include "wd_core.au3" #include "wd_helper.au3" Global $sDesiredCapabilities, $sSession, $sScriptName = "ZACKs dev" $_WD_DEBUG = $_WD_DEBUG_Info ; Set debug level: $_WD_DEBUG_None (0) = No logging to console, $_WD_DEBUG_Error (1) = Error logging to console, $_WD_DEBUG_Info (2) = Full logging to console (Default) Global $hSplash = SplashTextOn($sScriptName, "Running ZACKs ... please be patient!", Default, 45, 0, 0) ; ---------------------------------------------------------------------- ; Automate the website using FireFox. ; ----------------------------------------------------------------------------- ;This is 32B driver (copied from working demo, for example) Global $sDriver = "M:\Google Drive Folder\main\A TRADING 2023\SCRIPTS DEV\geckodriver.exe" ; <== Please modify this statement to your environment. Must be a local drive, network drives don't work! ; Setup Firefox _WD_Option("Driver", $sDriver) If @error Then Exit SetError(1, @error) _WD_Option('DriverParams', '--binary "C:\Program Files\WindowsApps\Mozilla.Firefox_110.0.0.0_x64__n80bbvh6b1yt2\VFS\ProgramFiles\Firefox Package Root\firefox.exe" --log trace ') _WD_Option('Port', 4444) $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}' ; End ------------------------------------------------------------------ _WD_Startup() If @error Then Exit SetError(2, @error) $sSession = _WD_CreateSession($sDesiredCapabilities) If @error Then Exit SetError(3, @error) ; ------------------------------------------------------------------------- ; Maximize browser window ; ----------------------------------------------------------------------------- _WD_Window($sSession, "Maximize") If @error Then Exit SetError(4, @error) ; --------------------------------------------------------------------- ControlSetText($hSplash, "", "Static1", "Opening website www.zacks.com") ; Open website _WD_Navigate($sSession, "http://www.zacks.com") ;_WD_Navigate($sSession, "https://www.zacks.com/stock/quote/HON") if @error Then Exit SetError(8, @error) ;Zacks Signin Global $sCommand = "VALUE" Global $sClkCommand = "CLICK" Global $sOption = "HON" Global $sCrLfOption = @CRLF ;Global $UsrNamOption = '"dgendrud@reagan.com"' Global $UsrNamOption = "dgendrud" Global $iStyle Global $sElement Global $VAT_Element = $sElement Global $SelElement Global $sUnameElement $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@class='signin_expand']") ;_WD_LinkClickByText($sSession, $sText[, $bPartial = Default[, $sStartElement = Default]]) This is the format _WD_LinkClickByText($sSession, "Sign In") ;_WD_ElementAction($sSession, $sElement, $sClkCommand, Default) NOTE: This does not work because this is a link to the sign in form!! $sUnameElement = _WD_GetElementByName($sSession, "username") ;$sUnameElement =_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "/html[1]/body[1]/header[1]/ul[1]/li[2]/div[1]/form[1]/div[1]/label[1]",Default,Default, BitOR($_WD_OPTION_Visible, $_WD_OPTION_Enabled)) ;_WD_ElementSelectAction($sSession, $sUnameElement, "DESELECTALL") ;_WD_ElementSelectAction($sSession, $sUnameElement, "SINGLESELECT") ;_WD_ElementAction($sSession, $sUnameElement, $sClkCommand, Default) ;TRY TO SELECT THE ELEMENT ;_WD_ElementSelectAction($sSession, $sSelectElement, $sCommand[, $vLabels = Default]) This is the format ;_WD_ElementSelectAction($sSession, $sUnameElement, "DESELECTALL") ;_WD_ElementSelectAction($sSession, $sUnameElement, "DESELECTALL") ;_WD_ElementSelectAction($sSession, $sUnameElement, "SELECTALL") _WD_ElementAction($sSession, $sUnameElement, "DISPLAYED") _WD_ElementAction($sSession, $sUnameElement, "ACTIVE") _WD_ElementAction($sSession, $sUnameElement, "ENABLED") _WD_ElementAction($sSession, $sUnameElement, "NAME") _WD_ElementAction($sSession, $sUnameElement, "PROPERTY") _WD_ElementAction($sSession, $sUnameElement, "SELECTED") _WD_ElementAction($sSession, $sUnameElement, "TEXT") _WD_ElementAction($sSession, $sUnameElement, "VALUE",$UsrNamOption) ;Sleep (2000) ;_WD_SetElementValue($sSession, $sUnameElement, $UsrNamOption) Sleep (100000) Exit ;NAVIGATE TO THE TICKER - THIS NAV WORKS FINE W/O THE TKR SYM VARIABLE ADDED ; (Works fine when the URL is just "https://www.zacks.com" ;With a 'FIXED" TICKER ("https://www.zacks.com/stock/quote/HON") IT ALSO NAV CORRECTLY ;NEED TO FIGURE OUT HOW TO INCLUDE THE VARIABLE IN THE STRING FOR THE URL! (I think just need to get the quotes around it) dim $tkrsym = "HON" $zacksURL = "https://www.zacks.com/stock/quote/" & $tkrsym ;Consolewrite( " zacksURL = " & $zacksURL & @CRLF) ;$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='login_form']//form[@class='jslogin_form']//div[@class='form-field float-label']//label[@for='username'][contains(text(),'Username or Email Address')]") ;$sElement = _WD_GetElementById($sSession, "close_login") ;$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='login_form']//form[@class='jslogin_form']//div[@class='form-field float-label']//label[@for='username'][contains(text(),'Username or Email Address')]") ;_WD_WaitElement($sSession, $sStrategy, $sSelector[, $iDelay = Default[, $iTimeout = Default[, $iOptions = Default]]]) ;_WD_ExecuteScript($sSession, "arguments[0].scrollIntoView(false);", __WD_JsonElement($VAT_Element)) ;Sleep (500) ;_WD_ElementAction($sSession, $sElement, $sClkCommand, Default) ;Sleep (1000) #cs _WD_ElementAction($sSession, $sElement, "CLICK",1) ;_WD_ElementAction($sSession, $sElement, "DISPLAYED",1) _WD_SetElementValue($sSession, $sElement, $UsrNamOption, "DEFAULT") ;_WD_ElementAction($sSession, $sElement, $sCommand, $UsrNamOption) Sleep (10000) Exit ;NAVIGATE TO THE TICKER - this works dim $tkrsym = "HON" $zacksURL = "https://www.zacks.com/stock/quote/" & $tkrsym ;Consolewrite( " zacksURL = " & $zacksURL & @CRLF) #ce #cs Global $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='search-q']") Global $sCommand = "VALUE" Global $sClkCommand = "CLICK" Global $sOption = "HON" Global $sCrLfOption = @CRLF ;Global $ClkOption = "" _WD_ElementAction($sSession, $sElement, $sCommand, $sOption) Global $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@id='ui-id-55']//div[@class='ticker_name']") Sleep (100) _WD_ElementAction($sSession, $sElement, $sClkCommand, Default) #ce #cs Exit sleep(10000) ;_WD_GetSource($sSession) ControlSetText($hSplash, "", "Static1", "Shutting down WebDriver automation") ;_WD_DeleteSession($sSession) If @error Then Exit SetError(6, @error) ;_WD_Shutdown() If @error Then Exit SetError(7, @error) SplashOff() MsgBox($MB_ICONINFORMATION, $sScriptName, "Finished!", 5) Exit #ce