
cbielich
Members-
Posts
12 -
Joined
-
Last visited
Everything posted by cbielich
-
Get HTML from DIV class name and loop
cbielich replied to cbielich's topic in AutoIt General Help and Support
ohhh got it, thanks! -
Get HTML from DIV class name and loop
cbielich replied to cbielich's topic in AutoIt General Help and Support
I got it! Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[contains(@class,'coverage-info')]") Local $sHTML = _WD_ElementAction($sSession, $sElement, 'property', 'innerHTML') $str = stringregexpreplace($sHTML,'\[b\]','') $str = stringregexpreplace($str,'\[/b\]','') $ret = stringregexp($str,'>(.*?)<',3) for $1 = ubound($ret) - 1 to 0 step -1 if stringlen(stringstripws($ret[$1],3)) = 0 then _arraydelete($ret,$1) next _arraydisplay($ret) Thanks to kylomas -
Get HTML from DIV class name and loop
cbielich replied to cbielich's topic in AutoIt General Help and Support
I also have noticed that _WD_ElementAction does not return as on object which I need for a For loop, is there a way to convert it to an object so I can loop through the elements? -
Get HTML from DIV class name and loop
cbielich replied to cbielich's topic in AutoIt General Help and Support
You are a god send! is there somewhere that better describes the "property" sCommand and what values are available? -
I am working with the web driver, back in the day when we had IE I had no issues with this but now...lol For the life of me I can't find out how to get the HTML within a DIV from its class name. I am using XPath to get the div by class. From my understand I need to use _WD_ElementAction to retrieve the "html", but the only thing I use that returns anything is "text" which obviously I can't use. I need the HTML so I can loop through them to parse out what I need. What am I doing wrong? <div class="coverage-info"> <div class="row"> <div class"class1">Some Title:</div> <div class="class2">Some value I need</div> </div> <div class="row"> <div class"class1">Some Title:</div> <div class="class2">Some value I need</div> </div> <div class="row"> <div class"class1">Some Title:</div> <div class="class2">Some value I need</div> </div> </div> Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[contains(@class,'coverage-info')]") Local $sValue = _WD_ElementAction($sSession, $sElement, 'text') Then I would loop through the elements with something like For $value In $sValue $class_value = $value.GetAttribute("class") If $class_value = "class1" Then MsgBox(0, "Found", $value.innertext) EndIf Next
-
I have some scripts I have been working on and I have noticed upon creating a new session with Edge the browser will not use the users current logged in Profile and instead uses something like "Profile 1" Is it possible to open Edge with the users current logged in profile? I am thinking this is done with capabilities when create a new session but I am not sure. $sCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"w3c": true }}}}' $result = _WD_CreateSession($sCapabilities)
-
I have a page that I need to be able to click on a button, but the class name for that button is only visible with inspecting element on the page and not the source code. I added Local $sHTML = $oDoc.documentElement.innerHTML hoping to be able to use that as the object then change Local $oInputs = _IETagNameGetCollection($oIE, "span") to Local $oInputs = _IETagNameGetCollection($sHTML, "span") hoping that would work, but of course it did not. Here is my full code. #include <IE.au3> $oIE = _IECreate("https://www.example.com/somethinghere/") Sleep(1000) $oDoc = _IEDocGetObj ($oIE) Local $sHTML = $oDoc.documentElement.innerHTML _IELoadWait($oIE) $i = 0 while $i <= 10 Local $oInputs = _IETagNameGetCollection($sHTML, "span") For $oInput In $oInputs If $oInput.className == "this-class-name" Then _IEAction($oInput, "click") Next Sleep(2000) WEnd Is it possible to click on an element that's only in the innerHTML and not the source code?
-
I know that this question has been asked a ton here, but most answers refer to getting the status bar message which I think is a great way. I have code that works and retrieves that message just fine. The problem I am coming across is there is no message displayed in IE11 when the page is loading like previous versions did. Some older versions used to display the word "Done" now there is nothing. Here is my code that does work. Func WaitLoad() Dim $state Run(@ProgramFilesDir & "\Internet Explorer\iexplore.exe " & $url, @ProgramFilesDir) WinWaitActive("Internet Explorer") Do $state = ControlGetText("Internet Explorer", "", "msctls_statusbar321") Sleep(250) Until $state = ""; Change this with the text that IE displays at the bottom left status bar, after the page is fully loaded. In my computer it says "Completed" in Greek :) MsgBox(0, "", "Success!") Exit EndFunc Except I have to leave status as Until $state = "" to make sure it triggers which it does, but of course this is not accurate since the only time anything appears on the status bar is when you hover over a link. Is there something different with IE 11?
-
I use GUIRegisterMsg($WM_COMMAND, "ED_WM_COMMAND") to capture Case $EN_SETFOCUS OR $EN_CLICK events. When using _IsPressed with Function Keys (F1 - F12) it does not work unless the function is the while 1 loop. I can get all my other events to trigger with _IsPressed just fine except Function Keys Working Example: (Click on Numpad 1 too see it work, F1 does not work #include <IE.au3> #include <Array.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <Misc.au3> #include <WindowsConstants.au3> #include <GuiComboBox.au3> #include <MsgBoxConstants.au3> Global $hGUI = GUICreate("Button", 700, 360) Global $hDLL = DllOpen("user32.dll") GUISetBkColor(0x00E0FFFF) GUISetFont(9, 300) GUICtrlCreateTab(10, 10, 680, 340) GUICtrlCreateTabItem("Content") GUICtrlSetState(-1, $GUI_SHOW) ; will be display first Global $button1 = GUICtrlCreateInput("", 20, 60, 53) GUISetState(@SW_SHOW, $hGUI) GUIRegisterMsg($WM_COMMAND, "ED_WM_COMMAND") Func ED_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $iCode = BitShift($wParam, 16) Switch $lParam Case GUICtrlGetHandle($button1) Switch $iCode Case $EN_SETFOCUS OR $EN_CLICK KeyDetect($button1) ;<== Here I am detecting which input field is clicked in to put a value into the input later EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>ED_WM_COMMAND Func KeyDetect($whichinput) ;This event below works fine calling (Numeric keypad 1 key) and placing into the input field a value of "N1" If _IsPressed("61", $hDLL) Then GUICtrlSetData($whichinput, "N1") EndIf ;This event below DOES NOT work calling (F1) and DOES NOT place a value of "F1" into the input field. If _IsPressed("70", $hDLL) Then GUICtrlSetData($whichinput, "F1") EndIf EndFunc While 1 $msg = GuiGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEndThe only way to get the If _IsPressed("70", $hDLL) Then EndIf To work is if I place it in the While 1 loop
-
GUICtrlCreateInput not letting me easily input into field
cbielich replied to cbielich's topic in AutoIt GUI Help and Support
Love you -
Weird issue but I have created a simple input field which works fine, except I have to click on a very specific part in order to get the cursor in there. I have adjusted the width and that seems to not effect it. Is there a way to make it easy to find the cursor? The input field works, just difficult to target the cursor into it Local $iDelayInput = GUICtrlCreateInput(0, 250, 75, 20, 20)