Jump to content
Danp2

WebDriver UDF - Help & Support

Recommended Posts

@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 
 

Share this post


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ÔľĀ

Share this post


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

Share this post


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

Share this post


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.

Share this post


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

 

Share this post


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
 

Share this post


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?


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

Share this post


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

 

Share this post


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.

 

Share this post


Link to post
Share on other sites
option.setExperimentalOption("useAutomationExtension", false); 
option.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));

If want to add the above parameters into [google: chromeOptions]

how do write it?

 

Share this post


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 Danp2
      Introduction
      This UDF will allow you to interact with any browser that supports the W3C WebDriver specifications. Supporting multiple browsers via the same code base is now possible with just a few configuration settings.
      Requirements
      JSON UDF https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn
      WinHTTP UDF https://www.autoitscript.com/forum/topic/84133-winhttp-functions/
      HtmlTable2Array UDF (optional) https://www.autoitscript.com/forum/topic/167679-read-data-from-html-tables-from-raw-html-source/
      WebDriver for desired browser
      Chrome WebDriver https://sites.google.com/a/chromium.org/chromedriver/downloads FireFox WebDriver https://github.com/mozilla/geckodriver/releases Edge WebDriver https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ Source Code
      You will always be able to find the latest version in the GitHub Repo 
      Help / Support
      See the wiki for details on the UDF --
      https://www.autoitscript.com/wiki/WebDriver
      Please post any questions, suggestions or errors in the GH&S thread.
      https://www.autoitscript.com/forum/topic/201106-webdriver-udf-help-support-ii/
    • By Jgladden
      Dan - thanks for all that you do - this stuff is great. 
      Hoping you can assist with an issue we are having now that we have moved to Windows 10/Server 2016. The Chrome interactions were working flawlessly until moving over. Now my code fails when attempting to create the session. As you can see, our Chrome install is not in a standard location but I have validated the path to the binary. I have attached some detail below including system info, console output and the chrome log detail. I have tried several recommendations that have seen in various forums but none have made a difference
      Any assistance you can give would be greatly appreciated. 
      Thanks in advance, 
      chrome_Details.txt
    • By Langmeister
      I am once again asking for your experienced assistance. If I open a website that uses notifications I am asked to allow or block them for that website after a few seconds. This notification pops up every time the page gets navigated to, even tho you have clicked on allow for several times. I am explicitly not searching for smth to get rid of "Chrome is being controlled by automated test sw". Instead I am searching for a line of script to disable all notifications by default: like here chrome://settings/content/notifications. 
      This is code should give you an example of what notifications I am talking about:
      #include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities, $sSession, $sID _WD_Option("Driver", "C:\Program Files (x86)\AutoIt3\chromedriver.exe") _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}' _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://webradio.planetradio.de/") _WD_LoadWait($sSession)  
    • By Langmeister
      Hi, I'm sure that this is a simple question regarding webdriver udf but my search on the forum did not result in the exact same scenario that I need. I will adapt it to my corporate needs but at first I want it to work with an example everybody can reproduce if needed.
      I navigate to https://www.daysoftheyear.com/ and want to find out what special day today is. Using the following Code returns the wanted text that today is 'shark awareness day' in the console but it is not pasted in notepad as it is not copied as it probably should be.
      #include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities, $sSession, $sID _WD_Option("Driver", "C:\Program Files (x86)\AutoIt3\chromedriver.exe") _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}' _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.daysoftheyear.com/?timezone_offset=nan") _WD_LoadWait($sSession) Sleep(3000) Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/div[2]/header/div/div[1]/div/div[2]/h3/a") _WD_ElementAction($sSession, $sElement, 'text') ClipGet() Run("notepad.exe") Sleep(500) Send("^v") Scite returns this, therefore the text has been found but the last mile to paste it to notepad or excel does not work for me.
      __WD_Get: URL=HTTP://127.0.0.1:9515/session/b72166b774d7fefb258b3721fc1d4306/element/657e6b5d-31a9-46a8-85c4-acb7f72bf659/text __WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"Shark Awareness Day"}... _WD_ElementAction: {"value":"Shark Awareness Day"}... Thanks in advance! 
       
    • By Langmeister
      Hi, I need help performing actions in Salesforce using IE. I used to complete tasks via MouseMove/MouseClick etc. on the Chrome application of SF, but unfortunately this only works for me and not my colleagues due to different positions of things etc. Being unable to get Webdriver UDF or Chromedriver running to interact with the code directly, I chose to look into the IE UDF. ATM I'm trying to tick a specific checkbox in SF which simply allows me to "select all checkboxes" at the same time. Applying the following code on a random website with checkboxes works just fine for me: (in this case selecting cheese checkbox)
      #include <IE.au3> Local $oIE = _IECreate("http://www.echoecho.com/htmlforms09.htm") Local $oSubmit = _IEGetObjByName($oIE, "option3") _IEAction($oSubmit, "click") _IELoadWait($oIE) But applying it to the Salesforce website it does exactly nothing and responds with these warnings/errors:
      The script is exactly the same, except for website and the input name tag of the desired checkbox being different.
      #include <IE.au3> Local $oIE = _IECreate("Corporate Salesforce URL") Local $oSubmit = _IEGetObjByName($oIE, "myPage:myForm:oliListBlock:oliListTable:j_id36") _IEAction($oSubmit, "click") _IELoadWait($oIE) As its working with random websites my guess is that there has to be something done to get it work with SF.
      Hope the more experienced SF+AutoIt pros can help me out here. Thanks in advance!
×
×
  • Create New...