Jump to content

WebDriver UDF - Help & Support


Recommended Posts

A new problem occured. I edit the program on windows server 2016. The geckodriver can't run at all whatever its version is 32 bit or 64 bit. All debug info is below:

"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\soft\autoit\autoit\au3\ad.au3"    
_WDStartup: OS:    WIN_2016 WIN32_NT 14393 
_WDStartup: AutoIt:    3.3.14.5
_WDStartup: WD.au3:    0.1.0.21
_WDStartup: Driver:    C:\soft\autoit\autoit\au3\geckodriver.exe
_WDStartup: Params:    --log trace --connect-existing  --marionette-port 2828
_WDStartup: Port:    4444
__WD_Post: URL=HTTP://127.0.0.1:4444/session; $sData={"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}}
__WD_Post: StatusCode=0; ResponseText=0
__WD_Post ==> Send / Recv error
_WD_CreateSession: 0
_WD_CreateSession ==> Webdriver Exception: HTTP status = 0
>Exit code: 0    Time: 1.979

It won't show the command window when I click the geckodriver.exe. 

However the same code can run well in local machine (Win10). I'm sure I close the firewall on windows server 2016. Somebody could help me??

Link to post
Share on other sites
  • 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

2 hours ago, tigerwang said:

A new problem occured. I edit the program on windows server 2016. The geckodriver can't run at all whatever its version is 32 bit or 64 bit. All debug info is below:

Sounds like this is an issue with your Windows installation, which isn't caused by this UDF. It's likely a security / rights issue. Have you tried the following?

  • Right click on the geckodriver executable
  • Select the Properties entry at the bottom
  • Look for and click the Unblock checkbox
Link to post
Share on other sites
41 minutes ago, Danp2 said:

Sounds like this is an issue with your Windows installation, which isn't caused by this UDF. It's likely a security / rights issue. Have you tried the following?

  • Right click on the geckodriver executable
  • Select the Properties entry at the bottom
  • Look for and click the Unblock checkbox

I tried,but it did't work.

Link to post
Share on other sites

Morning! Quick question, how do I get the value of an input field with WebDriver?

I know how to send values to an input field but I don't know how to read the value of an input field.

Local $woTrack   = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='nav_search_fld']")
    _WD_ElementAction($sSession, $woTrack, 'value', "work order tracking")
    _WD_ElementAction($sSession, $woTrack, 'text')

I use this to send data but I also want to check what value is in that field to make sure the data was properly sent. 

 

I figured it out: 

Here is the code I use to test against what was sent to the input field. 

; Send Data to Description
Local $eDescription = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='mad3161b5-tb2']")
Do
    _WD_ElementAction($sSession, $eDescription, 'value', $testDesc)
    _WD_ElementAction($sSession, $eDescription, 'text')

    Local $test92 = _WD_ElementAction($sSession, $eDescription, 'property', 'value')
    ConsoleWrite(@CRLF & "$test92: " & $test92 & @CRLF)
    Sleep(500)
Until $test92 = $testDesc

This is more effective and efficient than using sleep which may be skipped or waste large amounts of time. 

Edited by nooneclose
Figured out the solution
Link to post
Share on other sites

Hi everyone. I have this issue:

The webdriver returns the title of the page differently then _WD_GET displays it. This is in my log:

1571135606630   webdriver::server       DEBUG   -> GET /session/dd2a1e5d-f315-474f-bae9-84341b4af31c/title
1571135606632   webdriver::server       DEBUG   <- 200 OK {"value":"CAS – Central Authentication Service"}
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"CAS û Central Authentication Service"}...

It must have something to do with the charset. Anyone knows how to handle this issue?

Link to post
Share on other sites
5 hours ago, Danp2 said:

@phoving You'll need to provide more details. Some things to consider --

  • What is the default codepage for your Windows installation?
  • Are you running a non-English version of Windows?
  • Can you provide a short script that demonstrates the issue?

The default codepage is:

C:\>chcp
Active code page: 850

C:\>

The windows version is Dutch.

The script is very simple. I request the title of a page. The title of the page is: "CAS &ndash; Central Authentication Service".

But __WD_GET returns it as "CAS û Central Authentication Service". So if I want to check the title in my script it fails. This is the script where I get the title:

Func __EUP_GETTITLE()
    Local $sURL = $_WD_BASE_URL & ":" & $_WD_PORT & "/session/"& $__g_aEUP[$EUP_WD_SESSION][0] & "/title"
    Local $sResponse = __WD_Get($sURL)
    Local $sJSON = Json_Decode($sResponse)
    Return Json_Get($sJSON, "[value]")
EndFunc

 

Link to post
Share on other sites
On 10/15/2019 at 9:58 PM, Danp2 said:

@phoving You are using a function that was intended for internal use only by the UDF's other functions. Can you explain why you aren't using the standard _WD_* functions? Have you tried calling _WD_Action instead?

No special reason, but I think that has nothing to do with the issue I am experiencing. Calling _WD_Action instead has this result:

__WD_Get: URL=HTTP://127.0.0.1:4444/session/5b32358c-5a45-4e34-a370-0a6eceae403d/title
1571289885717   webdriver::server       DEBUG   -> GET /session/5b32358c-5a45-4e34-a370-0a6eceae403d/title
1571289885724   webdriver::server       DEBUG   <- 200 OK {"value":"CAS – Central Authentication Service"}
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"CAS û Central Authentication Service"}...
_WD_Action: {"value":"CAS û Central Authentication Service"}

I thought it has to do with the iMode in which _WinHttpSimpleRequest is called. I see this in the function header:

;                  $iMode       - [optional] reading mode of result
;                  |0 - ASCII-text
;                  |1 - UTF-8 text
;                  |2 - binary data

But in tests I did not see any solution.

Link to post
Share on other sites

@Danp2 I tested on an english windows, and got the same result.

I also changed the region settings / dat / time format etc. all to Central US.

You say you got the expected result. Is that: you got the same as I got, or do you get the "good" string? I do not understand how the webdriver can display the string correctly, but __WD_GET not.

 

Link to post
Share on other sites

@phoving This is what I got when testing both sites --

__WD_Get: URL=HTTP://127.0.0.1:9515/session/c3566cf2620999fd9d670c32ad9d82e3/title
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"CAS – Central Authentication Service"}...
_WD_Action: {"value":"CAS – Central Authentication Service"}

 

Link to post
Share on other sites
  • 2 weeks later...

Hey all,

I am having an issue getting the _WD functions to locate this link that I need to click on.

Link element that I need to click:

<a href="/admintool/servlet/servlet.FileDownload?file=00Pt000000ICYQHEA5" target="_BLANK" class="actionLink">Review.pdf</a>

Xpath:
//*[@id="j_id0:theForm:j_id31:j_id33:0:j_id36"]/a

iFrame that it is in:

<iframe allow="geolocation *; microphone *; camera *" frameborder="0" height="80%" id="j_id71" name="j_id71" src="website" title="Content" width="100%"></iframe>

What I have tried so far:

_WD_FrameEnter($sSession,"j_id71") ;I have tried all this code without entering the frame too
if @error Then MsgBox(0, "Frame", @error) ;Does not throw error so I know I am in the frame


_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='j_id0:theForm:j_id31:j_id33:0:j_id36']/a"), 0, 10000)
if @error Then MsgBox(0, "ByXpath", @error)

_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/form/div[2]/div/div/div[1]/table/tbody/tr/td[1]/a"), 0, 10000) ;Not sure if this even works but I tried it anyway
if @error Then MsgBox(0, "ByFullXpath", @error)

_WD_WaitElement($sSession, $_WD_LOCATOR_ByLinkText, "Review.pdf", 0, 10000)
if @error Then MsgBox(0, "ByLinkText", @error)

_WD_WaitElement($sSession, $_WD_LOCATOR_ByPartialLinkText, "Review.pdf", 0, 10000)
if @error Then MsgBox(0, "ByPartialText", @error)

_WD_WaitElement($sSession, $_WD_LOCATOR_ByPartialLinkText, "Review", 0, 10000)
if @error Then MsgBox(0, "ByPartialText2", @error)

_WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, ".actionLink")
if @error Then MsgBox(0, "ByCSS", @error)

All of these return @error = 7 (timeout) even though the element is loaded (takes half a second to appear on the screen) and I am completely stumped on another way to interact with it. And obviously since I cannot get my script to locate this element, all of the 'click' interactions return "No Match".

Anymore suggestions would be super helpful! Thanks!

PS: Unfortunately I cannot share this website since it has private information on it, but I will give as much info as I can.

Edited by Davidowicza
Link to post
Share on other sites

How To  set UserAgent?   I tried this:

_WD_Option('Driver', 'geckodriver.exe')
    _WD_Option('DriverParams', '--log trace')
    _WD_Option('Port', 4444)
    $sDesiredCapabilities = '{"desiredCapabilities":{"setWindowRect":true,"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true,"browserName":"chrome","browserVersion":"45"}}'

 

But it still shows the real useragent :firefox....... when use _WD_Navigate.

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 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
    • By goku200
      I am trying to change the settings of the print option to Save as PDF and its not changing the settings and clicking on the Save button at the bottom. Here is my script that I have written and the format is correct below. Chrome browser I'm using is 97.0 My script was working fine using Chrome 95.0\ Not sure why its not working now
      It finds the print-preview-app element but not the others.
       
×
×
  • Create New...