Jump to content

WebDriver UDF - Help & Support


Recommended Posts

9 hours ago, Danp2 said:

I've been doing some testing on this and want to be sure that we make the correct change. Can someone explain why I get the same result for the two split string values?

#include <MsgBoxConstants.au3>

Local $sSplitValue, $sSplitValue2
Local $sOption = 'ąśł'

MsgBox($MB_SYSTEMMODAL, "Original", $sOption)

$sSplitValue = "[" & StringTrimRight(StringRegExpReplace($sOption, '.', '"$0",'), 1) & "]"
$sSplitValue2 = "[" & StringTrimRight(StringRegExpReplace($sOption, '\\u[[:alnum:]]{4}|.', '"$0",'), 1) & "]"
MsgBox($MB_SYSTEMMODAL, "Split", $sSplitValue & @crlf & $sSplitValue2)

 

Because you didn't change characters to codes:

Local $sOption = 'ąśł'

should be

Local $sOption = '\u0105\u015B\u0142'

 

6 hours ago, Danp2 said:

@grzesiek

I believe that I have found the correct way to address the issue. Please change the following line in __WD_Post from

$sResponseText = _WinHttpSimpleRequest($hConnect, "POST", $aURL[6], Default, $sData)

to

$sResponseText = _WinHttpSimpleRequest($hConnect, "POST", $aURL[6], Default, StringToBinary($sData, 4))

and then retest with the Polish text.

It almost works but when I enter 'ćłą' I get some chinese character instead.

Link to comment
Share on other sites

1 hour ago, grzesiek said:

Local $sOption = '\u0105\u015B\u0142'

Like I said before, this isn't my area of expertise. :D I take another look at this.

1 hour ago, grzesiek said:

It almost works but when I enter 'ćłą' I get some chinese character instead.

That's odd. Can you post some code to demonstrate what you are seeing?

What you do get with the following?

#include <wd_core.au3>

Local Enum $eFireFox = 0, _
            $eChrome

Local Const $_TestType = $eChrome
Local $sDesiredCapabilities
Local $sText
Local $sSession

$_WD_DEBUG = $_WD_DEBUG_Info

Switch $_TestType
    Case $eFireFox
        SetupGecko()

    Case $eChrome
        SetupChrome()

EndSwitch

_WD_Startup()

$sText = 'ćłą'

$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "https://google.com")
$iElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='q']")
_WD_ElementAction($sSession, $iElement , 'value', $sText)

    $sValue = _WD_ElementAction($sSession, $iElement, 'property', 'value')

MsgBox(0, 'test', $sValue)

_WD_Window($sSession,'close')
_WD_DeleteSession($sSession)
_WD_Shutdown()


Func SetupGecko()
_WD_Option('Driver', 'geckodriver.exe')
_WD_Option('DriverParams', '--log trace')
_WD_Option('Port', 4444)

$sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}'
EndFunc

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

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true }}}}'
EndFunc

 

Link to comment
Share on other sites

I used the default 'Code Page Property' encoding. But strange to me is that it works with 'Code Page Property' if I change:

_WD_ElementAction($sSession, $iElement , 'value', $sText)

to

_WD_ElementAction($sSession, $iElement , 'value', $sText) ;ąśą

so If I add some random polish letters after calling the function.

Edited by grzesiek
Link to comment
Share on other sites

5 minutes ago, omarjr16 said:

there is anyway to run "pageLoadStrategy":"eager"  in chrome ?!  only none and normal work for me

Not until the functionality is implemented.

https://bugs.chromium.org/p/chromedriver/issues/detail?id=1902&q=pageLoadStrategy&colspec=ID Status Pri Owner Summary

7 minutes ago, omarjr16 said:

also there is anyway to check if the page is loading or no ?!

I've considered creating the function_WD_LoadWait. I actually wrote something a while back, but haven't really tested it.

Link to comment
Share on other sites

@Shaden Google is your friend when you can't find a prior example in the forum. ^_^

Read this for details on using "moz:firefoxOptions" as part of the capabilities string. Here's an example desired capabilities string --

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"moz:firefoxOptions": {"args": ["--private"]}}}}'

 

Link to comment
Share on other sites

@omarjr16 Try this and let me know how it works for you --

#include "wd_core.au3"
#include "wd_helper.au3"
Local $sDesiredCapabilities

Local Enum $eFireFox = 0, _
            $eChrome

Local Const $_TestType = $eFireFox

Switch $_TestType
    Case $eFireFox
        SetupGecko()

    Case $eChrome
        SetupChrome()

EndSwitch

_WD_Startup()

$sSession = _WD_CreateSession($sDesiredCapabilities)

_WD_Navigate($sSession, "http://www.google.com")
_WD_LoadWait($sSession, 500, 2000)
consolewrite('@error=' & @error & @CRLF)
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='q']")

_WD_Navigate($sSession, "http://www.yahoo.com")
_WD_LoadWait($sSession, -1, -1, $sElement)
consolewrite('@error=' & @error & @CRLF)

; #FUNCTION# ====================================================================================================================
; Name ..........: _WD_LoadWait
; Description ...: Wait for a browser page load to complete before returning
; Syntax ........: _WD_LoadWait($sSession[, $iDelay = 0[, $iTimeout = -1[, $sElement = '']]])
; Parameters ....: $sSession            - Session ID from _WDCreateSession
;                  $iDelay              - [optional] Milliseconds to wait before checking status
;                  $iTimeout            - [optional] Period of time to wait before exiting function
;                  $sElement            - [optional] Element ID to confirm DOM invalidation
; Return values .: Success      - 1
;                  Failure      - 0 and sets the @error flag to non-zero
; Author ........: Dan Pollak
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _WD_LoadWait($sSession, $iDelay = 0, $iTimeout = -1, $sElement = '')
    Local Const $sFuncName = "_WD_LoadWait"
    Local $iErr, $sResponse, $sJSON, $sReadyState

    If $iTimeout = -1 Then $iTimeout = $_WD_DefaultTimeout

    If $iDelay Then Sleep($iDelay)

    Local $hLoadWaitTimer = TimerInit()

    While True
        If $sElement <> '' Then
            _WD_ElementAction($sSession, $sElement, 'name')

            If $_WD_HTTPRESULT = $HTTP_STATUS_NOT_FOUND Then $sElement = ''
        Else
            $sResponse = _WD_ExecuteScript($sSession, 'return document.readyState', '')
            $iErr = @error

            If $iErr Then
                ExitLoop
            EndIf

            $sJSON = Json_Decode($sResponse)
            $sReadyState = Json_Get($sJSON, "[value]")

            If $sReadyState = 'complete' Then ExitLoop
        EndIf

        If (TimerDiff($hLoadWaitTimer) > $iTimeout) Then
            $iErr = $_WD_ERROR_Timeout
            ExitLoop
        EndIf

        Sleep(100)
    WEnd

    If $iErr Then
        Return SetError(__WD_Error($sFuncName, $iErr, ""), 0, 0)
    EndIf

    Return SetError($_WD_ERROR_Success, 0, 1)
EndFunc


Func SetupGecko()
_WD_Option('Driver', 'geckodriver.exe')
_WD_Option('DriverParams', '--log trace')
_WD_Option('Port', 4444)

$sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true, "pageLoadStrategy":"none"}}'
EndFunc

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

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true}, "pageLoadStrategy":"none"}}}'
EndFunc

 

Link to comment
Share on other sites

One of our environments got a bunch of updates over the last weekend, and since then I have not been able to get chromedriver.exe to work in that env.

Chrome opens, but sits at an empty data;, page.

I have been using the little demo script I posted in the UDF thread to try and troubleshoot, but it never really gets anywhere..

What the chrome.log shows

Quote

[1537282533.137][INFO]: Launching chrome: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-infobars --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-automation --enable-logging --force-fieldtrials=SiteIsolationExtensions/Control --ignore-certificate-errors --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=0 --start-maximized --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\...\scoped_dir32208_17987" data:,
[1537282533.718][INFO]: resolved localhost to ["::1","127.0.0.1"]
[1537282543.201][SEVERE]: Unable to receive message from renderer
[1537282543.240][INFO]: [62635baf2551f036527e7ff4b5fb4b8e] RESPONSE InitSession ERROR session not created
from disconnected: Unable to receive message from renderer
  (Session info: chrome=69.0.3497.92)

 

Now for the extra strange part.  If I switch over to use headless via:  "args":["headless", "disable-gpu", "disable-infobars"]  the script works fine.

All I can find using google searches says to use the latest chromedriver.exe which I already am, or to submit a bug to chromium.

Link to comment
Share on other sites

I'm using the v2.42.  I was using 2.40 but part of the updates this last weekend was updating chrome to 69 which forced me to use the newer chromedriver.

I keep thinking there must be some new security policy or restriction put into place but our Infrastructure & Security team keep telling me there weren't any changes like that.

 

edit:  Just tried the 2.41 since it will also support 69 and it's having the same problem.

Edited by BigDaddyO
Link to comment
Share on other sites

am I missing something simple?

I'm trying to select an item from a drop down but I don't see any method to select an item from a list.  I tried to send a click, but that didn't work.

$eHIPPAtype = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//select[contains(@id,'callerTypeOptions') and not(contains(@id, 'callerTypeOptions1')) and contains(@class, 'callerTypeOptions')]")
$eHIPPAtypeMbr = _WD_FindElement($sSession, "//option[contains(@value, 'Member')][1]", $eHIPPAtype, False)  ;Starting at the Select list, find the first object that contains Member as thats what I want


_WD_ElementAction($sSession, $eHIPPAtypeMbr, "click")   ;Click doesn't work, how do I select?

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...