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

@damp

I solve my problem making delay  like following and after iall is working 

$sbutton= _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath,"//button[@id='action.save' and @name='action'  and @class='btn btn-md btn-primary col-md-3 pull-right']")
Local $test92 = _WD_ElementAction($sSession, $sbutton, 'click')
sleep(1000)

Thanks 
 

Link to post
Share on other sites
#include <Array.au3>
#include 'wd_helper.au3'

$_WD_DEBUG = False
Global $sDesiredCapabilities
Global $sSession

_SetupIE()
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)

_Example()

Func _Example()
    _WD_Navigate($sSession, "https://docs.microsoft.com/en-us/windows/win32/controls/window-controls")

     $aTables = _WD_FindElement($sSession,"tag name", "table", '', True)
     if @error=0 then
        _ArrayDisplay($aTables)
     Else
        ConsoleWrite("@error=" & @error & @CRLF)
    EndIf
EndFunc

Func _SetupIE()
    _WD_Option('Driver', 'IEDriverServer.exe')
    _WD_Option('Port', 5555)
    _WD_Option('DriverParams', '--log-file=' & @ScriptDir & '\IE.log')
    $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}'
EndFunc   ;==>_SetupIE

An error occurred after running the above code, as follows:

_WDStartup: OS    : WIN_7 WIN32_NT 7601 Service Pack 1
_WDStartup: AutoIt: 3.3.14.2
_WDStartup: WD.au3: 0.1.0.19
_WDStartup: Driver: IEDriverServer.exe
_WDStartup: Params: --log-file=I:\IE.log
_WDStartup: Port  : 5555

__WD_Post: URL=HTTP://127.0.0.1:5555/session; $sData={"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}

__WD_Post: StatusCode=200; ResponseText={
    "value" : 
    {
        "capabilities" : 
        {
            "acceptInsecureCerts" : false,
            "browserName" : "internet explorer",
            "browserVersion" : "11",
            "pageLoadStrategy" : "normal",
            "platformName" : "windows",
            "proxy" : {},
            "se:ieOptions" : 
            {
                "browserAttachTimeout" : 0,
                "elementScrollBehavior" : 0,
                "enablePersistentHover" : true,
                "ie.browserCommandŤ°Ć.witches" : "",
                "ie.ensureCleanSession" : false,
                "ie.fileUploadDialogTimeout" : 3000,
                "ie.forceCreateProcessApi" : false,
                "ignoreProtectedModeSettings" : false,
                "ignoreZoomSetting" : false,
                "initialBrowserUrl" : "http://localhost:5555/",
                "nativeEvents" : true,
                "requireWindowFocus" : false
            },
            "setWindowRect" : true,
            "timeouts" : 
            {
                "implicit" : 0,
                "pageLoad" : 300000,
                "script" : 30000
            },
            "unhandledPromptBehavior" : "dismiss"
        },
        "sessionId" : "b8a652a9-be13-4ec2-8fa9-24a36795371a"
    }
}

_WD_CreateSession: {
    "value" : 
    {
        "capabilities" : 
        {
            "acceptInsecureCerts" : false,
            "browserName" : "internet explorer",
            "browserVersion" : "11",
            "pageLoadStrategy" : "normal",
            "platformName" : "windows",
            "proxy" : {},
            "se:ieOptions" : 
            {
                "browserAttachTimeout" : 0,
                "elementScrollBehavior" : 0,
                "enablePersistentHover" : true,
                "ie.browserCommandŤ°Ć.witches" : "",
                "ie.ensureCleanSession" : false,
                "ie.fileUploadDialogTimeout" : 3000,
                "ie.forceCreateProcessApi" : false,
                "ignoreProtectedModeSettings" : false,
                "ignoreZoomSetting" : false,
                "initialBrowserUrl" : "http://localhost:5555/",
                "nativeEvents" : true,
                "requireWindowFocus" : false
            },
            "setWindowRect" : true,
            "timeouts" : 
            {
                "implicit" : 0,
                "pageLoad" : 300000,
                "script" : 30000
            },
            "unhandledPromptBehavior" : "dismiss"
        },
        "sessionId" : "b8a652a9-be13-4ec2-8fa9-24a36795371a"
    }
}

__WD_Post: URL=HTTP://127.0.0.1:5555/session/b8a652a9-be13-4ec2-8fa9-24a36795371a/url; $sData={"url":"https://docs.microsoft.com/en-us/windows/win32/controls/window-controls"}

__WD_Post: StatusCode=200; ResponseText={
    "value" : null
}

_WD_Navigate: {
    "value" : null
}

__WD_Post: URL=HTTP://127.0.0.1:5555/session/b8a652a9-be13-4ec2-8fa9-24a36795371a/elements; $sData={"using":"tag name","value":"table"}

__WD_Post: StatusCode=404; ResponseText={
    "value" : 
    {
        "data" : null,
        "error" : "no such window",
        "message" : "Currently focused window has been closed.",
        "stacktrace" : ""
    }
}

[_WD_FindElement: {
    "value" : 
    {
        "data" : null,
        "error" : "no such window",
        "message" : "Currently focused window has been closed.",
        "stacktrace" : ""
    }
}]

@error=9

why?

thanks in advanceÔľĀ

Link to post
Share on other sites

Dear @Danp2
I am new and I look forward to your support in this regard:
I saw the example in the demo file and it seems that it only has an example of WD_Action with mouse:
$sAction = '{"actions":[{"id":"default mouse","type":"pointer","parameters":{"pointerType":"mouse"},"actions":[{"duration":100,"x":0,"y":0,"type":"pointerMove","origin":{"ELEMENT":"'
$sAction &= $sElement & '","' & $_WD_ELEMENT_ID & '":"' & $sElement & '"}},{"button":2,"type":"pointerDown"},{"button":2,"type":"pointerUp"}]}]}'
I want to send the {pagedown} key in WD, what should I do?
Thank you!

Edited by nguyenthaiytcc
Link to post
Share on other sites

How can i change the select option with the following sentence 

<div role="combobox" class="v-filterselect v-widget v-has-width" style="width: 20em;">

<input type="text" class="v-filterselect-input" autocomplete="nope" id="gwt-uid-3" aria-labelledby="gwt-uid-2" tabindex="0" dir="" style="width: 100%;">

<div class="v-filterselect-button" aria-hidden="true" role="button"></div></div>

My code 

$sTouche =_WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='gwt-uid-3']")
    _WD_ElementAction($sSession, $sTouche, 'property','')
_ChromeSetInputValueById($sSession,'gwt-uid-3','English')

And the debugger 

__WD_Post: URL=HTTP://127.0.0.1:9515/session/4ed0969e6701ee585ee758f05deb98f3/element; $sData={"using":"xpath","value":"//input[@id='gwt-uid-3']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"5472b4ed-0b82-4bf2-b75f-4fbde4f8a117"}}
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"5472b4ed-0b82-4bf2-b75f-4fbde4f8a117"}}
__WD_Get: URL=HTTP://127.0.0.1:9515/session/4ed0969e6701ee585ee758f05deb98f3/element/5472b4ed-0b82-4bf2-b75f-4fbde4f8a117/property/
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":null}...
_WD_ElementAction: {"value":null}...
__WD_Post: URL=HTTP://127.0.0.1:9515/session/4ed0969e6701ee585ee758f05deb98f3/element; $sData={"using":"xpath","value":"//input[@id='gwt-uid-3']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"5472b4ed-0b82-4bf2-b75f-4fbde4f8a117"}}
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"5472b4ed-0b82-4bf2-b75f-4fbde4f8a117"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/4ed0969e6701ee585ee758f05deb98f3/element/5472b4ed-0b82-4bf2-b75f-4fbde4f8a117/value; $sData={"id":"5472b4ed-0b82-4bf2-b75f-4fbde4f8a117", "text":"English"}
__WD_Post: StatusCode=200; ResponseText={"value":null}
_WD_ElementAction: {"value":null}...
+>15:21:34 AutoIt3.exe ended.rc:0
+>15:21:34 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 22.66

Beforei have "Deutsch" in the input and after i have DeutschEnglish in the fields 
 

Edited by loulou2522
Link to post
Share on other sites

@nguyenthaiytcc This isn't something that I've needed to do previously, but I believe this would be the basic syntax --

$sAction = '{"actions":[{"type": "key", "id": "keyboard_1", "actions": [{"type": "keyDown", "value": "\uE00F"}, {"type": "keyUp", "value": "\uE00F"}]}]}'
_WD_Action($sSession, "actions", $sAction)

Please give it a try and report back with your results.

Link to post
Share on other sites

@loulou2522 I suggest that you post a short reproducer that we can actually run to observe whatever issue you are encountering.

P.S. No idea what the 2nd line is supposed to be doing. If you are attempting to clear the prior value, this this would make more sense --

_WD_ElementAction($sSession, $sTouche, 'clear')

 

Link to post
Share on other sites
$sSession = _WD_CreateSession($sDesiredCapabilities)
;_WD_Window($sSession, 'Maximize')
_WD_Navigate($sSession,"https://ubs-paymentstandards.ch/login")
Sleep(1000)

$sTouche =_WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='gwt-uid-3']")
    _WD_ElementAction($sSession, $sTouche, 'clear')
    Sleep(2000)
_ChromeSetInputValueById($sSession,'gwt-uid-3','English')

Sleep(1000)
exit

Here is the code to reproduce this case . Hope it will be suffisant for you to show the problem
 

Link to post
Share on other sites
On 11/29/2019 at 5:03 PM, Letraindusoir said:

An error occurred after running the above code.....

hello @Letraindusoir, your code snippet works properly here, (win 7 x64 & ie 11) have you solved your problem?

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to post
Share on other sites

@loulou2522 This isn't a standard web element, so it takes multiple steps to accomplish your goal. The follow example will open the web page and then switch back and forth between English and Deutsch.

#include "wd_core.au3"
#include "wd_helper.au3"

Local $sDesiredCapabilities
Local $sSession, $sElement, $sElement2

SetupChrome()
_WD_Startup()

If @error <> $_WD_ERROR_Success Then
    Exit -1
EndIf

$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession,"https://ubs-paymentstandards.ch/login")
Sleep(1000)

; Click arrow to open dropdown list
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@class='v-filterselect-button']")
_WD_ElementAction($sSession, $sElement, 'click')

; Wait for element to be present and then click it
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//span[contains(text(),'English')]", 1000)
$sElement2 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[contains(text(),'English')]")
_WD_ElementAction($sSession, $sElement2, 'click')

Sleep(2500)

; Click arrow to open dropdown list
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@class='v-filterselect-button']")
_WD_ElementAction($sSession, $sElement, 'click')

; Wait for element to be present and then click it
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//span[contains(text(),'Deutsch')]", 1000)
$sElement2 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[contains(text(),'Deutsch')]")
_WD_ElementAction($sSession, $sElement2, 'click')


Func SetupChrome()
_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"excludeSwitches": ["enable-automation"]}}}}'
EndFunc

 

Link to post
Share on other sites
15 hours ago, Chimp said:

hello @Letraindusoir, your code snippet works properly here, (win 7 x64 & ie 11) have you solved your problem?

Yes, I can now run it correctly by searching for relevant information. However, the IE browser needs to be set in advance.„Äā

The Configuration Required are as follows:

Quote
  • On IE 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. The value can be on or off, as long as it is the same for every zone. To set the Protected Mode settings, choose "Internet Options..." from the Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode".
  • Additionally, "Enhanced Protected Mode" must be disabled for IE 10 and higher. This option is found in the Advanced tab of the Internet Options dialog.
  • The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.
  • For Windows 10, you also need to set "Change the size of text, apps, and other items" to 100% in display settings.
  • For IE 11 only, you will need to set a registry entry on the target computer so that the driver can maintain a connection to the instance of Internet Explorer it creates. For 32-bit Windows installations, the key you must examine in the registry editor is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. For 64-bit Windows installations, the key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. Please note that the FEATURE_BFCACHE subkey may or may not be present, and should be created if it is not present. Important: Inside this key, create a DWORD value named iexplore.exe with the value of 0.

 

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 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
       

    • By TTE26
      For the past two days I've been reading all Wiki pages, installed all the demos etc. but I am still unable to do this simple workflow
      1. I want to use WebDriver UDF to open Chrome (Set chrome option arguments - Window Size, Pixel ratio, device type and platform name, user-agent.)
      2. On new Tab I want to read the tab Title and save it into a TXT file.
      3. I need to save the Session ID with my previosly set Capabilities into a file.
      4. I want to close the chrome window.
      Then
      5. I want to open Chrome again, but with my previosly saved Session ID and Capabilities list from the file.
      6. And minimaze the window state.
      7. After 30 seconds, close the chrome.
      I would really appreciate for the WebDriver UDF Helper file, to have also basic code examples, for non coders. For example how to open a windwow etc., save sessions, etc.
      Anyway, if someone could help me get started and help me with this workflow, that would¬†be much appreaciated.¬†ūüėĒ
    • By lapoelkan12
      hi i try to use webdriver  i download it and  download json and  winhttp i try to run it  but  return error
       error: __WinHttpVer(): undefined function.
              Local $sWinHttpVer = __WinHttpVer()
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
       
       

    • By levila
      Hi Guys, i just do some codding to automate login to some of the web.
      I manage to do the script but somehow after script done, some weird box popup. and keep looping until i close the main chrome.exe

      here is my code. kinldy pls assist, im very new to webdriver udf.
      #NoTrayIcon #include "wd_core.au3" #include "wd_helper.au3" $_WD_DEBUG = $_WD_DEBUG_None ; You could also use $_WD_DEBUG_Error Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://someoftheweb.com") _ChromeSetInputValueByName($sSession, "inputName", "Username") _ChromeSetInputValueById($sSession, "inputPassword", "Password") _ChromeSetMouseClick($sSession, "submit", "click") _WD_Shutdown() Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--no-sandbox"]}}}}' EndFunc Func _ChromeSetInputValueByName($sSession,$name,$Value) $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='"&$name&"']") _WD_ElementAction($sSession,$sButton,'value', $Value) EndFunc Func _ChromeSetInputValueById($sSession,$Id,$Value) $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='"&$Id&"']") _WD_ElementAction($sSession,$sButton,'value', $Value) EndFunc Func _ChromeSetMouseClick($sSession,$Id,$Value) $sButton = _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//button[@type='"&$Id&"']") _WD_ElementAction($sSession, $sButton, 'click', $Value) EndFunc  
    • By RohanM
      Hi Team,
      is there is a way to embed the webpage in auto it GUI using webdriver? what I want to do is that, I want to open edge browser inside the AutoIT GUI, in IE we have _IECreateEmbedded function but for the webdriver I am not able to find a function, please help  
      Rohan M
×
×
  • Create New...