Jump to content

WebDriver UDF - Help & Support


Recommended Posts

  • Replies 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

This is the "General Help and Support" thread for the WebDriver UDF. The UDF itself can be downloaded here. So if you have any questions, suggestions or errors please post here.

use the _WD_ElementAction function like this: $sValue = _WD_ElementAction($sSession, $sElement, 'attribute', 'src') p.s. ... and remove @src from the xPath: "//img[@alt='NiceGirl']"

Time ago I wrote a function to extract data from  the source HTML code of tables. https://www.autoitscript.com/forum/topic/167679-read-data-from-html-tables-from-raw-html-source/ Seems that that fun

Posted Images

Yes, you were right. I found this code (click 2) attached to the link element. If I click on "trigger event" it opens the upload tab as it should. (but not with Autoit) Do you see a problem with this code? Click 1 code is visible on the screenshot.

function (event) {
    var $this = $(this),
        method = $this.data('method'),
        message = $this.data('confirm'),
        form = $this.data('form');
 
    if (method === undefined && message === undefined && form === undefined) {
        return true;
    }
 
    if (message !== undefined) {
        $.proxy(pub.confirm, this)(message, function () {
            pub.handleAction($this, event);
        });
    } else {
        pub.handleAction($this, event);
    }
    event.stopImmediatePropagation();
    return false;
}

Screenshot (4).png

Link to post
Share on other sites

@_leo_ You have two different click events attached to the link. When you clicked "trigger event", I believe you were triggering the first click event, which is different code than what you posted above. This is the actual code attached to that event --

function(e) {
  !0 === e ? (ga("send", {
    hitType: "event",
    eventCategory: "FileLibrary",
    eventAction: "Default file upload"
  }), $(this.nodeFilter).find("input[type=file]").click()) : PF.FileLibrary.CopyrightWarning.showPopup($.proxy(this.onDefaultUploadClick, this, !0, !1))
}

 

Link to post
Share on other sites

FYI, I just ran the following in Chrome and it triggered the file upload dialog for me --

_WD_Navigate($sSession, "https://www.printful.com/dashboard/library")
$Upload = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@class='btn btn-danger btn-block' and contains(text(),'Upload')]")
_WD_ElementAction($sSession, $Upload, 'click')

 

Link to post
Share on other sites

Thank you very much @Danp2, that sounds very promising! 

When I clicked "trigger event" it triggered the file upload dialog on both click events attached to the element. I do not understand where you got this different Javascript code from. As you can see on the screenshot, the code attached to the Upload button seems to be another one than yours.

If I try to trigger the event with the same code, I still don't get a reaction. Could it be that the problem is not caused by a javascript error? This would explain why it works for you.

I am very thankful that you created an account just to help - that is so kind.

412688758_Screenshot(6).thumb.png.ac6c2046110c59a411f87f62465dfb12.png

Edited by _leo_
Link to post
Share on other sites

I downloaded the newest release of the UDF, tried to use the 78 chromedriver (that does not work at all) and checked if Javascript was still enabled in the chrome settings. None of the actions solved the problem. Maybe I should try it on my other laptop...

Quote

_WDStartup: OS:    WIN_10 WIN32_NT 17763 
_WDStartup: AutoIt:    3.3.14.5
_WDStartup: WD.au3:    0.1.0.21
_WDStartup: Driver:    chromedriver.exe
_WDStartup: Params:    --log-path="C:\Users\leona\Desktop\chrome.log"
_WDStartup: Port:    9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars", "user-data-dir=userdata"] }}}}
__WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"77.0.3865.90","chrome":{"chromedriverVersion":"77.0.3865.40

Link to post
Share on other sites

There are some things that  I don't quite understand about _ WD_ExecuteScript.

_WD_ExecuteScript($sSession, $sScript, $sArguments = "[]", $lAsync = False)

$sData = '{"script":"' & $sScript & '", "args":[' & $sArguments & ']}'

If there are three parameters

Arguments[0]=100

Arguments[1]="Status"

Arguments[2]=@CRLF

_WD_ExecuteScript($Session, $sScript, $sArguments)

how do I write '$sArguments' ?

_WD_ExecuteScript($Session, $sScript,'100,"Status",@CRLF')

or 

_WD_ExecuteScript($Session, $sScript,'[100,"Status",@CRLF]')

Is that so?

Link to post
Share on other sites

@Letraindusoir The brackets are added by _WD_ExecuteScript automatically, so I would say that the first one is the better of the two attempts.

Both _WD_NewTab and _WD_GetElementFromPoint pass multiple parameters to _WD_ExecuteScript, so you may want to review those functions for other working examples.

Link to post
Share on other sites

Good morning, Danp2. Quick question. I am having issues sending data to a field.

I am wanting to send data to a Long Description Box that pops up when its clicked. 

Here is a picture of what I am talking about: (Trying to send data to the green highlighted box, the red box is the details about that element)

315537226_Screenshot(35).thumb.png.8ce61fc6cbd8fc751c66185080b9cbb6.png

The box is a div with an id of "dijitEditorBody".

Here is the code I have so far. (edited: I doubt you want all 230 lines)

;===============================================================================
    ; Send Data to the Long Description
    ; Clicks the Long Description Button
    Local $wLongok   = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//img[@id='mad3161b5-img2']")
    _WD_ElementAction($sSession, $wLongok, 'click')
    Sleep(5000)
    
    ; Sends the Long Description to the LongD TextBox
    Local $eDescription   = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='dijitEditorBody']")
    _WD_ElementAction($sSession, $eDescription, 'value', "Can I add a Long Description or are you just joshing me?")
    _WD_ElementAction($sSession, $eDescription, 'text')
    Sleep(500)
    
    ; Clicks OK to close TextBox
    Local $wLongok   = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@id='m74031266-pb']")
    _WD_ElementAction($sSession, $wLongok, 'click')
    Sleep(500)

everything else works except for the long description. I do not know if its because a new window appears or if its because it is a "div".

As always any help would be greatly appreciated. 

Link to post
Share on other sites

@Danp2 Thank you for getting back with me. I did find out about the iframe but I don't really know how to handle it.

The best I could come up with was: (this didn't work, I do not know how to properly handle iframes.)

Local $eDescription   = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//iframe[@id='ma6499a9c-rte_iframe']")
    _WD_ElementAction($sSession, $eDescription, 'value', "Can I add a Long Description or are you just joshing me?")
    _WD_ElementAction($sSession, $eDescription, 'text')
    Sleep(500)

 

Link to post
Share on other sites

I'm sorry im still not understanding what to do with iframes. I ran the demo multiple times and I ran that demo code in my script and I still do not understand what I am supposed to do with them. 

These are the results I get in my script: (from the code below)

Frames=3
TopWindow=True
TopWindow=False
TopWindow=True

here is the code I used:

ConsoleWrite(@CRLF & @CRLF & @CRLF & @CRLF & "Frames=" & _WD_GetFrameCount($sSession) & @CRLF)
    ConsoleWrite("TopWindow=" & _WD_IsWindowTop($sSession) & @CRLF)
    $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//iframe[@id='ma6499a9c-rte_iframe']")
    _WD_FrameEnter($sSession, $sElement)
    ConsoleWrite("TopWindow=" & _WD_IsWindowTop($sSession) & @CRLF)
    _WD_FrameLeave($sSession)
    ConsoleWrite("TopWindow=" & _WD_IsWindowTop($sSession) & @CRLF)

Am I supposed to perform an action? after I enter the frame? 

Edited by nooneclose
Link to post
Share on other sites

@Danp2 Hello, I have a confusing question. Remember yesterday how I got my code to work on my test site. Welp, I can not get it to run on the live site. :( 

There is almost no difference between the test and the live site. (the only difference I have found is that sometimes the id's are different)

Here is the code I have to send data to the "div" inside of the "iframe":

; Click the Long Description button
        Local $wLongDB = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//img[@id='m65d795a4-img']")
        _WD_ElementAction($sSession, $wLongDB, 'click')
        Sleep(5000)

        ConsoleWrite(@CRLF & @CRLF & @CRLF & @CRLF & "Frames=" & _WD_GetFrameCount($sSession) & @CRLF)
        ConsoleWrite("TopWindow=" & _WD_IsWindowTop($sSession) & @CRLF)


        $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//iframe[@id='ma6499a9c-rte_iframe']")
        _WD_FrameEnter($sSession, $sElement)
        ConsoleWrite(@CRLF & @CRLF & @CRLF & @CRLF & "Frames=" & _WD_GetFrameCount($sSession) & @CRLF)
        ConsoleWrite("TopWindow=" & _WD_IsWindowTop($sSession) & @CRLF)
        Local $wLongTxtBox   = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='dijitEditorBody']")
        _WD_ElementAction($sSession, $wLongTxtBox, 'value', $eComments)
        _WD_ElementAction($sSession, $wLongTxtBox, 'text')
        _WD_FrameLeave($sSession)


        ConsoleWrite(@CRLF & @CRLF & @CRLF & @CRLF & "Frames=" & _WD_GetFrameCount($sSession) & @CRLF)
        ConsoleWrite("TopWindow=" & _WD_IsWindowTop($sSession) & @CRLF)
        Sleep(3500)


        ; Click the ok button
        Sleep(2000)
        Local $wLongOk = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@id='m74031266-pb']")
        _WD_ElementAction($sSession, $wLongOk, 'click')
        Sleep(2500)

Here are the iframe results:

Frames=2
TopWindow=True

Frames=0
TopWindow=False

Frames=2
TopWindow=True

 

here is a picture of the HTML code:

2126363342_Screenshot(36).thumb.png.e018d18fa90b33780abe56afc008dea7.png

I'm 100% sure like the test site there is the only one iframe I need to enter and leave. But I can't understand why it's not working. 

As always any help would be appreciated.  :) 

Link to post
Share on other sites
On 10/7/2019 at 1:43 AM, Danp2 said:

@Letraindusoir The brackets are added by _WD_ExecuteScript automatically, so I would say that the first one is the better of the two attempts.

Both _WD_NewTab and _WD_GetElementFromPoint pass multiple parameters to _WD_ExecuteScript, so you may want to review those functions for other working examples.

Thank you, Dan! Notice that it's separated by quotation marks and commas into a string.

Link to post
Share on other sites

I did a lot of testing and I found out that it is entering the iframe properly and is finding the element right (checked this by highlighting the element)

I believe it is not sending the variable data because of some hidden characters in the variable.

The length of the plain text is:  812

The length of the variable is: 819

Any hints/tips/ideas as to why the variable is 7 chars bigger?

I get the variable by reading in data from an email. I chop the email up with "StringSplit" a lot maybe some invisible chars are not getting chopped?    

Link to post
Share on other sites
41 minutes ago, nooneclose said:

Any hints/tips/ideas as to why the variable is 7 chars bigger?

I get the variable by reading in data from an email. I chop the email up with "StringSplit" a lot maybe some invisible chars are not getting chopped?    

Hard to say since we can't test it. Have you examined the results from the Scite output panel? Make sure that you set

$_WD_DEBUG = $_WD_DEBUG_Info

so that you get max details output.

Link to post
Share on other sites

I think I found the problem. Is there a special space char that Autoit cant handle? at the end of both string after stripping @CR, @LF, @TAB and @CRLF the only difference between the two string was that one had a different space char at the end. The "ASCII code" for that char is 32 which makes no sense to me why it causes the variable to fail to send. (if I copy the plain text of that same string it works just fine)  

Link to post
Share on other sites
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By corvo
      Hello!

      I've been trying to launch chrome through WD,  but for some reason, the user profile is not working, it just opens up the chrome window with the "temp" user. I've also made sure that the user profile path is correct by using "chrome://version". 
      Here is what I've got so far:
      #include "wd_helper.au3" #include "wd_capabilities.au3" #include "wd_core.au3" SetupChrome() _WD_CapabilitiesStartup() Local $sCapabilities = _WD_CapabilitiesGet() $sSession = _WD_CreateSession($sCapabilities) _WD_Navigate($sSession, "https://www.google.com") Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"') _WD_Option('DriverParams', '--marionette-port 2828') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Profile 2"]}}}}' $_WD_DEBUG = $_WD_DEBUG_None ; You could also use $_WD_DEBUG_Error EndFunc  
      Thanks in advance!
       
    • By ThomasBennett
      Good morning, everyone, 
      I have had very good luck with using _WD_ElementActionEx 'CLICKANDHOLD'. What would be the best practice with dragging and dropping web elements? I would prefer to not to have to use any dragging and dropping but I haven't figured out a way to change the order the elements are displayed programmatically. 
      I have a list of elements that are drag and drop. These elements in code are using <UL></UL> for the entire list and the actual web elements that are being manipulated are in <LI></LI> tags. These do not look like a bulleted list but that is the code that is being used. I've spoken with the web developer and there isn't any hot keys or keyboard commands that can be used to move these elements.
      I know where the new and original web element appears and can select them using the _WD_WaitElement and _WD_FindElement combo. I can find the number of items in the list by looking at the code; I haven't started pulling the values out just yet. I am trying to figure out if there is a place to change the listed order.
      Using the 'CLICKANDHOLD' feature as part of _WD_ElementActionEx does work and I know more or less where I need to drop it the new web element; the problem I am having is scrolling exactly to where I need the new web element dropped. It should be dropped beneath the original web element. 
      What's the best method to output the number of children associated with the <UL></UL>? I am guessing that _WD_ElementActionEx 'CHILDCOUNT' would be it; but I haven't figured out how to get the call to output in a msgbox or in the console. 
      #cs ---------------------------------------------------------------- Name ..........: Please Note!.au3 Description ...: To be used to add new lessons to existing playlists and to update the pre-existing lesson with the Please Note! PowerPoint SciTE 32-bit ..: Version 4.4.6 Author(s) .....: Thomas E. Bennett Date ..........: 20220929 Recommended Reading / Requirements https://www.autoitscript.com/forum/topic/191990-webdriver-udf-w3c-compliant-version-01162021/#comments https://www.autoitscript.com/wiki/WebDriver https://www.autoitscript.com/wiki/WebDriver#Installation https://www.autoitscript.com/wiki/Adding_UDFs_to_AutoIt_and_SciTE https://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine wd_core.au3 wd_helper.au3 From wd_core.au3 Global Const $_WD_LOCATOR_ByCSSSelector = "css selector" Global Const $_WD_LOCATOR_ByXPath = "xpath" Global Const $_WD_LOCATOR_ByLinkText = "link text" Global Const $_WD_LOCATOR_ByPartialLinkText = "partial link text" Global Const $_WD_LOCATOR_ByTagName = "tag name" #ce ---------------------------------------------------------------- #include "wd_core.au3" #include "wd_helper.au3" #include <MsgBoxConstants.au3> #include <Excel.au3> #include <AutoItConstants.au3> Local $sDesiredCapabilities, $sSession, $sElement ; Create application object and open an example workbook Local $oExcel = _Excel_Open() If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\{PRIVACY}.xlsx") If @error Then MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error opening workbook '" & @ScriptDir & "\{PRIVACY}.xlsx'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) Exit EndIf ; Read data from a single cell on the active sheet of the specified workbook ;Local $sResult = _Excel_RangeRead($oWorkbook, Default, "A1") ;If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 1", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 1", "Data successfully read." & @CRLF & "Value of cell A1: " & $sResult) SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) Sleep (15000) Local $aResult = _Excel_RangeRead($oWorkbook, Default, "A16:E16") For $i = 0 To UBound($aResult, 1) - 1 ;ConsoleWrite("========= Start Row =========" & @CRLF) ;ConsoleWrite($aResult[$i][0] & @CRLF) ; Column A -- Course Playlist Number ;ConsoleWrite($aResult[$i][1] & @CRLF) ; Column B -- Course Playlist Title ;ConsoleWrite($aResult[$i][2] & @CRLF) ; Column C -- Original Lesson Title ;ConsoleWrite($aResult[$i][3] & @CRLF) ; Column D -- Updated Lesson Number ;ConsoleWrite($aResult[$i][4] & @CRLF) ; Column E -- Updated Lesson Title ;ConsoleWrite("========= End Row =========" & @CRLF & @CRLF) _WD_Navigate($sSession, "{PRIVACY}" & $aResult[$i][0]) _WD_LoadWait($sSession, 2000) ; Find the Available Lessons search box and enter the appropriate value _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='titleSearch']") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='titleSearch']") ; Click the Sign in button _WD_ElementAction($sSession, $sElement, 'value', $aResult[$i][3]) Send("{Enter}") ; Find the correct "Add" hyperlink _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//span[text()='" & $aResult[$i][4] & "']/following-sibling::div") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[text()='" & $aResult[$i][4] & "']/following-sibling::div") ; Click the "Add" hyperlink _WD_ElementAction($sSession, $sElement, 'click') ; Number of Child Elements _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//ul[@id='selected-items']") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//ul[@id='selected-items']") _WD_ElementActionEx($sSession, $sElement, 'CHILDCOUNT') Exit ; Click and Hold the appropriate element _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//ul[@id='selected-items']//span[@class='item-description' and text()='" & $aResult[$i][4] & "']/parent::li") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//ul[@id='selected-items']//span[@class='item-description' and text()='" & $aResult[$i][4] & "']/parent::li") _WD_ElementActionEx($sSession, $sElement, 'clickandhold', 0, 0, 0, 10000) ; Hover the appropriate element _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//ul[@id='selected-items']//span[@class='item-description' and text()='" & $aResult[$i][4] & "']/following-sibling::a") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//ul[@id='selected-items']//span[@class='item-description' and text()='" & $aResult[$i][4] & "']/following-sibling::a") _WD_ElementActionEx($sSession, $sElement, 'HOVER') Exit Next Exit _WD_DeleteSession($sSession) _WD_Shutdown() Exit Func SetupChrome() ; Google Chrome _WD_Option('Driver', "C:\Users\thomas.bennett\Desktop\AutoIt\include\chromedriver.exe") _WD_Option('Port', 9515) ;_WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"unhandledPromptBehavior": "ignore", ' & _ '"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false, ' & _ '"prefs": {"credentials_enable_service": false},' & _ '"args": ["start-maximized"] }}}}' EndFunc Console Output
      >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\thomas.bennett\Desktop\AutoIt\Please Note!\Please Note!.au3" /UserParams +>09:22:40 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0) Keyboard:00000409 OS:WIN_10/2009 CPU:X64 OS:X64 Environment(Language:0409) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\thomas.bennett\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\thomas.bennett\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.5) from:C:\Program Files (x86)\AutoIt3 input:C:\Users\thomas.bennett\Desktop\AutoIt\Please Note!\Please Note!.au3 +>09:22:40 AU3Check ended.rc:0 >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\thomas.bennett\Desktop\AutoIt\Please Note!\Please Note!.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. _WD_Option ==> Success [0] : Parameters: Option=Driver Value=C:\Users\thomas.bennett\Desktop\AutoIt\include\chromedriver.exe _WD_Option ==> Success [0] : Parameters: Option=Port Value=9515 _WD_IsLatestRelease ==> Success [0] : True _WD_Startup: OS: WIN_10 WIN32_NT 22000 _WD_Startup: AutoIt: 3.3.14.5 _WD_Startup: Webdriver UDF: 0.10.1 (Up to date) _WD_Startup: WinHTTP: 1.6.4.2 _WD_Startup: Driver: C:\Users\thomas.bennett\Desktop\AutoIt\include\chromedriver.exe (32 Bit) _WD_Startup: Params: _WD_Startup: Port: 9515 _WD_Startup: Command: "C:\Users\thomas.bennett\Desktop\AutoIt\include\chromedriver.exe" _WD_Startup ==> Success [0] __WD_Post ==> Success [0] : HTTP status = 200 _WD_CreateSession ==> Success [0] : 2542b35e47b8f9b2558cd92ad1418811 __WD_Post ==> Success [0] : HTTP status = 200 _WD_Navigate ==> Success [0] : Parameters: URL={PRIVACY} _WD_LoadWait ==> Success [0] : Parameters: Delay=2000 Timeout=Default Element=Default _WD_WaitElement ==> Success [0] : Parameters: Strategy=xpath Selector=//input[@id='Username'] Delay=Default Timeout=Default Options=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_FindElement ==> Success [0] : Parameters: Strategy=xpath Selector=//input[@id='Username'] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_ElementAction ==> Success [0] : Parameters: Command=value Option=<masked> _WD_WaitElement ==> Success [0] : Parameters: Strategy=xpath Selector=//input[@id='Password'] Delay=Default Timeout=Default Options=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_FindElement ==> Success [0] : Parameters: Strategy=xpath Selector=//input[@id='Password'] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_ElementAction ==> Success [0] : Parameters: Command=value Option=<masked> _WD_WaitElement ==> Success [0] : Parameters: Strategy=xpath Selector=//input[@value='Sign In'] Delay=Default Timeout=Default Options=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_FindElement ==> Success [0] : Parameters: Strategy=xpath Selector=//input[@value='Sign In'] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_ElementAction ==> Success [0] : Parameters: Command=click Option=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_Navigate ==> Success [0] : Parameters: URL={PRIVACY} _WD_LoadWait ==> Success [0] : Parameters: Delay=2000 Timeout=Default Element=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_Navigate ==> Success [0] : Parameters: URL={PRIVACY} _WD_LoadWait ==> Success [0] : Parameters: Delay=2000 Timeout=Default Element=Default _WD_WaitElement ==> Success [0] : Parameters: Strategy=xpath Selector=//input[@id='titleSearch'] Delay=Default Timeout=Default Options=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_FindElement ==> Success [0] : Parameters: Strategy=xpath Selector=//input[@id='titleSearch'] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_ElementAction ==> Success [0] : Parameters: Command=value Option=<masked> _WD_WaitElement ==> Timeout [7] : Parameters: Strategy=xpath Selector=//span[text()='{PRIVACY}']/following-sibling::div Delay=Default Timeout=Default Options=Default __WD_Post ==> No match [8] : HTTP status = 404 _WD_FindElement ==> No match [8] : Parameters: Strategy=xpath Selector=//span[text()='{PRIVACY}']/following-sibling::div StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> No match [8] : HTTP status = 404 _WD_ElementAction ==> No match [8] : Parameters: Command=click Option=Default _WD_WaitElement ==> Success [0] : Parameters: Strategy=xpath Selector=//ul[@id='selected-items'] Delay=Default Timeout=Default Options=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_FindElement ==> Success [0] : Parameters: Strategy=xpath Selector=//ul[@id='selected-items'] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_ExecuteScript ==> Success [0] _WD_ElementActionEx ==> Success [0] : Parameters: Element=21c01052-8b86-4058-b8f6-d9dfa750f9ee Command=CHILDCOUNT XOffset=Default YOffset=Default Button=Default HoldDelay=Default Modifier=Default +>09:23:20 AutoIt3.exe ended.rc:0 +>09:23:20 AutoIt3Wrapper Finished. >Exit code: 0 Time: 40.88  

      My thought is once AutoIt knows how many child elements there are; I am hoping that there would be a way to change the sort or priority order that the <LI></LI>'s are shown in. 
      Thank you for your time and efforts on this and as I progress I'll update this topic, 




      Thomas 
    • By ThomasBennett
      #cs ---------------------------------------------------------------- Name ..........: ignore.au3 Description ...: Testing _WD_HighlightElements SciTE 32-bit ..: Version 4.4.6 Author(s) .....: Thomas E. Bennett Date ..........: 20220929 Recommended Reading / Requirements https://www.autoitscript.com/forum/topic/191990-webdriver-udf-w3c-compliant-version-01162021/#comments https://www.autoitscript.com/wiki/WebDriver https://www.autoitscript.com/wiki/WebDriver#Installation https://www.autoitscript.com/wiki/Adding_UDFs_to_AutoIt_and_SciTE https://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine wd_core.au3 wd_helper.au3 From wd_core.au3 Global Const $_WD_LOCATOR_ByCSSSelector = "css selector" Global Const $_WD_LOCATOR_ByXPath = "xpath" Global Const $_WD_LOCATOR_ByLinkText = "link text" Global Const $_WD_LOCATOR_ByPartialLinkText = "partial link text" Global Const $_WD_LOCATOR_ByTagName = "tag name" #ce ---------------------------------------------------------------- #include "wd_core.au3" #include "wd_helper.au3" #include "wd_cdp.au3" #include "wd_capabilities.au3" #include <MsgBoxConstants.au3> Local $sDesiredCapabilities, $sElement, $sSession Func SetupChrome() ; Google Chrome _WD_Option('Driver', @ScriptDir & "\include\chromedriver.exe") _WD_Option('Port', 9515) ;_WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"unhandledPromptBehavior": "ignore", ' & _ '"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false, ' & _ '"prefs": {"credentials_enable_service": false},' & _ '"args": ["start-maximized"] }}}}' EndFunc SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) Sleep (15000) ; DuckDuckGo _WD_Navigate($sSession, "https://duckduckgo.com/") _WD_LoadWait($sSession, 2000) ; Find the Search field _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='search_form_input_homepage']") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='search_form_input_homepage']") ; Highlight the Search field _WD_HighlightElements($sSession, $sElement, 3) MsgBox(0,"","") Exit ;this is here on purpose _WD_DeleteSession($sSession) _WD_Shutdown() Exit Good evening, everyone, 
      I am trying to get any element to highlight using the _WD_HighlightElements function; I've tried different elements and for a time I thought maybe because I am working in Windows 11 so I switched back to Windows 10 same issue; I can't get the found element to highlight. What am I doing incorrectly?
      Console Output _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"0e212d4f-8437-42a0-a56a-bc8694fe6e66"}} _WD_WaitElement ==> Success __WD_Post: URL=HTTP://127.0.0.1:9515/session/0e05f8ea99dba06bb84908b0b46fe881/element; $sData={"using":"xpath","value":"//input[@id='search_form_input_homepage']"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"0e212d4f-8437-42a0-a56a-bc8694fe6e66"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"0e212d4f-8437-42a0-a56a-bc8694fe6e66"}} Thank you for your time on this,




      Thomas E. Bennett
    • By SkysLastChance
      I am having trouble finding a good way to click these "button" below. 

      I only need to be able to click them when they have both yes/no. Otherwise I don't have to worry about them. For instance if they looked like this I would NOT have worry about clicking them and can just ignore them all togheter.(Below Picture)

      The problem is as mentioned in the title, all of the ID's  are dynamic. (Classes too)

      Here is what it looks like if yes is already selected.

      This is what I was using to select the the button. However, I need to know if the button has already been clicked/selected or not.
      _WD_LoadWait($sSession) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[text() = 'Offered access to electronic health information?']") Sleep(1000) _WD_ElementAction($sSession, $sElement, 'click') Sleep(500) _WD_Action($sSession, "actions", $sActionTab) Sleep(500) _WD_Action($sSession, "actions", $sActionEnter) Is there a way I can get the count of spans in the span class-"s_636" by tabbing over to the button? I am hoping someone might have some ideas on what I can try.
      Unfortunally, The site is for work so giving the site wont do any good. 
    • By ThomasBennett
      Good morning, everyone, 
      I am using WebDriver with ChromeDriver version 105.0.5195.52
      I have the script almost completed; this is going to be used as a wait / pause until the file has completed uploading. I was able to find where the value: "C:\\fakepath\\Vladimir Harkonnen.jpg" is stored. I am trying to figure out how to read this value. This is part of an <input type="file"> element. Reading / finding the value would be the trigger to allow the script to continue. I don't know very much but I feel like I am either not using WebDriver correctly or possibly it won't be able to help me with what I am trying to do.
      Please see the attached screenshot. 
      Thank you for your time, experience, and patience with me,




      Thomas Bennett
       

×
×
  • Create New...