Jump to content
Danp2

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

Share this post


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

Share this post


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.

Share this post


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

Share this post


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?

Share this post


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

 

Share this post


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.

Share this post


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.

 

Share this post


Link to post
Share on other sites
On 10/13/2019 at 4:42 AM, Danp2 said:

Have you looked into the :contains selector? That should allow you to accomplish your goal.

Yes it took me sometime to figured it out!! Thank you so much!!!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

@Danp2

Thank you again! I figured I had to be missing something obvious... Spent about 4 hours trying to figure it out but never guessed it was because of how I was entering the iFrame...it works like a charm!

Edited by Davidowicza

Share this post


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.

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