Jump to content

Hermes

Active Members
  • Posts

    40
  • Joined

  • Last visited

Reputation Activity

  1. Like
    Hermes reacted to Dryden in WebDriver UDF - Help & Support (III)   
    OK, thanks for the advice on _WD_Window. I think i got it working:
    _WD_Window($sSession, 'Switch', '{"handle":"' & $sTab1 & '"}') $Source = _WD_GetSource($sSession) FileWrite("in1.temp", $Source) _WD_Window($sSession, 'Switch', '{"handle":"' & $sTab2 & '"}') $Source = _WD_GetSource($sSession) FileWrite("ri1.temp", $Source) _WD_Window($sSession, 'Switch', '{"handle":"' & $sTab3 & '"}') $Source = _WD_GetSource($sSession) FileWrite("re1.temp", $Source) You talked about retrieving InnerText property of the body element, can you give me a generic example on how to do that?
    Sorry, I'm new to this UDF and am trying to integrate it in an alder script that used _IE

    Another question, i noticed the when i use
     
    _WD_Window($sSession, "minimize", "") It minimizes the window, but as soon as i focus on another tab it shows the window again. Is there a property to keep it minimized or even hidden?
  2. Like
    Hermes reacted to NguyenLe in WebDriver UDF (W3C compliant version) - 2024/09/21   
    @Danp2 If I connect to a new tab and reconnect to the previous tab I can not get the text of the alert
    My Code: 
    _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, 'http://google.com') _WD_ExecuteScript($sSession, 'window.open()','{}') $Handle = _WD_Window($sSession, 'handle', '') ;Sleep(500) _WD_NewTab($sSession, True) Sleep(500) _WD_Window($sSession, 'Switch' ,'{"handle":"' & $Handle & '"}') Sleep(500) _WD_ExecuteScript($sSession, "alert('testing 123')") Sleep(1000) $aHandles = _WD_Window($sSession, 'handles', '') $sTabHandle = $aHandles[UBound($aHandles) - 1] _WD_Window($sSession, 'Switch', '{"handle":"' & $sTabHandle & '"}') Sleep(1000) _WD_Window($sSession, 'Switch' ,'{"handle":"' & $Handle & '"}') Sleep(1000) $Text = _WD_Alert($sSession, 'gettext') _WD_Alert($sSession, 'accept') MsgBox(0,'Test Alert Text',$Text) My Console:
    _WD_Alert: {"value":{"error":"no alert open","message":"(Session infochrome=64.0.3282.140)","stacktrace":"Backtrace:\n\t(No symbol) [0x0117C2F0]\n\t(No symbol) [0x0116473D]\n\t(No symbol) [0x01133D93]\n\t(No symbol) [0x0113045D]\n\t(No symbol) [0x010F3CA3]\n\t(No symbol) [0x01115B6A]\n\t(No symbol) [0x010F38F7]\n\t(No symbol) [0x011159FB]\n\t(No symbol) [0x011006B4]\n\t(No symbol) [0x01101C86]\n\t(No symbol) [0x01101C09]\n\tGetHandleVerifier [0x01196C37+62007]\n\t(No symbol) [0x01180453]\n\t(No symbol) [0x0114CF76]\n\t(No symbol) [0x0114D365]\n\t(No symbol) [0x0114D47E]\n\t(No symbol) [0x01182527]\n\t(No symbol) [0x0114CCBF]\n\t(No symbol) [0x0114DFBF]\n\t(No symbol) [0x01149D6B]\n\t(No symbol) [0x01149EC3]\n\t(No symbol) [0x0115BEB9]\n\tBaseThreadInitThunk [0x7703336A+18]\n\tRtlInitializeExceptionChain [0x77569882+99]\n\tRtlInitializeExceptionChain [0x77569855+54]\n"}}  

  3. Thanks
    Hermes reacted to Danp2 in Instantly set textarea content based on the value of the clipboard without using sendkeys and setelementvalue   
    The Webdriver "actions" is an advanced feature that can be difficult to format correctly. In this case, the string of actions isn't properly formatted, so the Webdriver is throwing an error. Here's a simplified example that worked for me --
    ; Press ctrl $sAction = '{"actions":[{"type": "key", "id": "keyboard_1", "actions": [{"type": "keyDown", "value": "\uE009"},' ; Pause $sAction &= '{"type": "pause", "duration": 500},' ; Press v $sAction &= '{"type": "keyDown", "value": "v"}, {"type": "keyUp", "value": "v"},' ; Release ctrl $sAction &= '{"type": "keyUp", "value": "\uE009"}]}]}' _WD_Action($sSession, "actions", $sAction)  
  4. Thanks
    Hermes reacted to junkew in Can't click print page elements that is displayed in front of main window   
    Maybe this helps
    https://stackoverflow.com/questions/11537103/how-to-handle-print-dialog-in-selenium
  5. Like
    Hermes reacted to Danp2 in Unable to select elements inside the frame src   
    Seems like your CSS is wrong for locating the frameset. Once you resolve that, there are commands for switching context so that you can access the frame's contents. You need to use _WD_Window with the correct parameters or you can use the helper functions _WD_FrameEnter and _WD_FrameLeave.
    P.S. You can't use the $sStartNodeID parameter of _WD_FindElement to access a frame's contents.
  6. Thanks
    Hermes reacted to Nine in How to select the 3rd identical element   
    $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "div:nth-of-type(3)") Maybe ?
  7. Like
    Hermes got a reaction from TheXman in How to find an element using attribute that has special characters in it   
    Thanks, it all makes sense now. I just modified the line (see below), and it now worked!
    _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByCSSSelector, "test-accordion[accordion-list='[""name"":'test"",""label"":""testname""}]']", $test2)  
  8. Thanks
    Hermes reacted to TheXman in How to find an element using attribute that has special characters in it   
    Compare the line below to your original line to see the differences.  Then read the Help file's section on strings to understand why the line below is able to be parsed correctly.
    _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByCSSSelector, "test-accordion[accordion-list=""[{'name':'test','label':'testname'}]""]", $test2)  
  9. Thanks
    Hermes reacted to water in _Excel_RangeCopyPaste not copying B:E range for each row   
    Use the counter to determine the row to copy:
    Local $oRange, $oTest Local $iStartLine = 0 ; First index of $aArray2 to process For $i = 0 To UBound($aArray2) - 1 If $i < $iStartLine Then ContinueLoop $oRange = $oWorkbook.ActiveSheet.Range("B" & $i + 1 & ":E" & $i + 1) $temprf &= $aArray2[$i] _Excel_RangeCopyPaste($oWorkbook.Activesheet, $oRange) $oTest = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "PasteButton") ;This button will paste values from the Clipboard once clicked _WD_ElementAction($sSession, $oTest, 'click')) Next In addition I have
    Moved the Local definition out of the loop Replaced $Skipline with $iStartLine because your code only skipped a single line, not all lines up to the specified line
  10. Thanks
    Hermes reacted to Nine in Array is not matching with the second array   
    Here what your code could be if I understand you correctly :
    #Include "wd_core.au3" #Include "wd_helper.au3" #Include <Excel.au3> #Include <Array.au3> Local $sDesiredCapabilities = SetupChrome() _WD_Startup() Local $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "file://C:\\Applications\\AutoIt\\WebDriver\\HTML Examples\\Table.html") _WD_LoadWait($sSession) Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//table[@class='test']") ConsoleWrite ("Table " & $sElement & @CRLF) Local $aArray1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, ".//td[contains(.,'Title')]", $sElement, True) For $i = 0 to UBound($aArray1) - 1 $aArray1[$i] = _WD_ElementAction($sSession, $aArray1[$i], 'text') Next _ArrayDisplay($aArray1) Local $aElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, ".//a[@class='testlink']", $sElement, True) _ArrayDisplay($aElement) Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\test.xlsx") Local $aArray2 = _Excel_RangeRead($oWorkbook, Default,"B2:B6") _Excel_Close($oExcel) _ArrayDisplay($aArray2) ; search from Excel array cells into Chrome table Local $iIdx For $i = 0 To UBound($aArray2) - 1 $iIdx = _ArraySearch($aArray1, $aArray2[$i]) If @error Then ContinueLoop ConsoleWrite ("Found at " & $iIdx & @CRLF) _WD_ElementAction($sSession, $aElement[$iIdx], 'click') Next ;_WD_DeleteSession($sSession) ;_WD_Shutdown() Local $aDir = _FileListToArrayRec(@TempDir, "scoped_dir*;chrome_*", $FLTAR_FOLDERS, $FLTAR_NORECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) Sleep(2000) For $i = 1 To $aDir[0] DirRemove($aDir[$i], $DIR_REMOVE) Next Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') Return '{"capabilities":{"alwaysMatch":{"goog:chromeOptions":{"w3c":true,' & _ '"excludeSwitches":["enable-automation"],"useAutomationExtension":false}}}}' EndFunc ;==>SetupChrome  
  11. Thanks
    Hermes reacted to Nine in Array is not matching with the second array   
    You should read your excel sheet starting at row 2 since you have a title.
    Look at _WD_FindElement there is a starting element (4th parameter), I think you will need it...
  12. Like
    Hermes got a reaction from Danp2 in ElementAction and ElementOptionSelect alternatives   
    @Danp2This has been solved, i was referencing an incorrect element to click on. 
×
×
  • Create New...