Jump to content

Recommended Posts

Posted

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

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

Posted (edited)

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
Posted

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?

Posted
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

 

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

Posted

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

 

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

  • 2 weeks later...
Posted (edited)

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
Posted (edited)

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

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.

Guest
This topic is now closed to further replies.
×
×
  • Create New...