Jump to content

WebDriver UDF - Help & Support (II)


Danp2
 Share

Recommended Posts

ok, so now another issue. I'm attempting to automate chrome's print dialog, and i don't think it can be done entirely using the UDF, but it can do most of the heavy lifting. The big issue i'm getting is that if i launch a website, then execute "window.print();" to bring up the chrome print dialog, it starts causing WinHTTP timeouts

 

_WD_Navigate($sSession, "www.amd.com")
_WD_Timeouts($sSession, '{"pageLoad":30000,"script":30000}')

_WD_ExecuteScript($sSession,"window.print();")
$bth_PrintDialog = _WD_Attach($sSession, "print-preview-destination-select", "html")

Debug output surrounding the ExecuteScript to the attach line:

__WD_Post: URL=HTTP://127.0.0.1:9515/session/a7ab956a33b643e039ebd6de6c00290f/execute/sync; $sData={"script":"window.print();", "args":[]}
__WD_Post: StatusCode=500; ResponseText={"value":{"error":"script timeout","message":"script timeout\n  (Session info: chrome=83.0.4103.97)"...
__WD_Post ==> Webdriver Exception: {"value":{"error":"script timeout","message":"script timeout\n  (Session info: chrome=83.0.4103.97)","stacktrace":"Backtrace:\n\tOrdinal0 [0x002F9563+2725219]\n\tOrdinal0 [0x001F8551+1672529]\n\tOrdinal0 [0x000E0202+524802]\n\tOrdinal0 [0x000944C1+214209]\n\tOrdinal0 [0x0008AA9D+174749]\n\tOrdinal0 [0x00093D7C+212348]\n\tOrdinal0 [0x0008A94B+174411]\n\tOrdinal0 [0x00072528+75048]\n\tOrdinal0 [0x000735A0+79264]\n\tOrdinal0 [0x00073539+79161]\n\tOrdinal0 [0x0020D607+1758727]\n\tGetHandleVerifier [0x00416546+1050150]\n\tGetHandleVerifier [0x00416291+1049457]\n\tGetHandleVerifier [0x004210D7+1094071]\n\tGetHandleVerifier [0x00416B46+1051686]\n\tOrdinal0 [0x00205B06+1727238]\n\tOrdinal0 [0x0020EB7B+1764219]\n\tOrdinal0 [0x0020ECE3+1764579]\n\tOrdinal0 [0x00224C05+1854469]\n\tBaseThreadInitThunk [0x76B26359+25]\n\tRtlGetAppContainerNamedObjectPath [0x76F98944+228]\n\tRtlGetAppContainerNamedObjectPath [0x76F98914+180]\n\t(No symbol) [0x00000000]\n"}}
_WD_ExecuteScript: {"value":{"error":"script timeout","message":"script timeout\n  (Session info: chrome=83.0.4103.97)"...
_WD_ExecuteScript ==> Webdriver Exception: HTTP status = 500
__WD_Get: URL=HTTP://127.0.0.1:9515/session/a7ab956a33b643e039ebd6de6c00290f/window/handles
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":["CDwindow-B2F9D47446A947DEE0AC1032599E0714","CDwindow-18ED5501A6EE11E225B865F6FB03AEA5"]}...
_WD_Window: {"value":["CDwindow-B2F9D47446A947DEE0AC1032599E0714","CDwindow-18ED5501A6EE11E225B865F6FB03AEA5"]}...
__WD_Get: URL=HTTP://127.0.0.1:9515/session/a7ab956a33b643e039ebd6de6c00290f/window
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"CDwindow-B2F9D47446A947DEE0AC1032599E0714"}...
_WD_Window: {"value":"CDwindow-B2F9D47446A947DEE0AC1032599E0714"}...
__WD_Post: URL=HTTP://127.0.0.1:9515/session/a7ab956a33b643e039ebd6de6c00290f/window; $sData={"handle":"CDwindow-B2F9D47446A947DEE0AC1032599E0714"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Window: {"value":null}...
__WD_Get: URL=HTTP://127.0.0.1:9515/session/a7ab956a33b643e039ebd6de6c00290f/source
__WD_Get: StatusCode=0; $iResult = 6; $sResponseText=WinHTTP request timed out before Webdriver...
__WD_Get ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_GetSource: WinHTTP request timed out before Webdriver
_WD_GetSource ==> Send / Recv error: WinHTTP request timed out before Webdriver
__WD_Post: URL=HTTP://127.0.0.1:9515/session/a7ab956a33b643e039ebd6de6c00290f/window; $sData={"handle":"CDwindow-18ED5501A6EE11E225B865F6FB03AEA5"}
__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...
__WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_Window: WinHTTP request timed out before Webdriver...
_WD_Window ==> Send / Recv error: HTTP status = 0

 

Link to comment
Share on other sites

1 hour ago, Cyphon68 said:

The big issue i'm getting is that if i launch a website, then execute "window.print();" to bring up the chrome print dialog, it starts causing WinHTTP timeouts

Don't do that! 😅

What are you wanting to accomplish? Are you wanting to print to file, physical printer, or something else???

Link to comment
Share on other sites

Can you point me the way to enter a website that as login/password, to fill a webform that is inside? i mean i dont want to fill the login page as i am already in in another firefox page, as it assumes i am not login in, i assume it as do to with cookies.

; Move to the requested website
_WD_Navigate($sSession, "https://www.xxxxx.com")

; Anything you want to do after navigating to the website goes here

$Book = _WD_GetElementByName($sSession, "name")
If Not @error Then _WD_SetElementValue($sSession, $Book, "1321321321321231321321321")

 

 

Link to comment
Share on other sites

6 minutes ago, Romano71 said:

It says i have no profile.

It is kind of tempting to make a joke on this one ;)  But I will refrain myself. 

Make sure you got the full path to your profile.  In the Wiki for FireFox, the username is missing...

Link to comment
Share on other sites

Yes iam such a noob, sorry 😂, trying to learn.

but now it gives another session error:

__WD_Post: URL=HTTP://127.0.0.1:4444/session; $sData={"capabilities":{"alwaysMatch": {"moz:firefoxOptions": {"args": ["-profile", "C:/Users/myname/AppData/Roaming/Mozilla/Firefox/Profiles/rehwwfrx.default"],"log": {"level": "trace"}}}}}
__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...
__WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_CreateSession: WinHTTP request timed out before Webdriver
_WD_CreateSession ==> Webdriver Exception: HTTP status = 0

qE2PL8N.png

 

Link to comment
Share on other sites

@Romano71 Please post the complete output so that we can see potential issues with UDF versions, etc.

@Nine You can update the wiki entry 😉

P.S. Just wrote this as a way to grab the default profile --

Local $sDefault, $sProfilePath = ''

Local $sProfilesPath = StringReplace(@AppDataDir, '\', '/') & "/Mozilla/Firefox/"
Local $sFilename = $sProfilesPath & "profiles.ini"
Local $aSections = IniReadSectionNames ($sFilename)

; Check if an error occurred.
If Not @error Then
    ; Enumerate through the array displaying the section names.
    For $i = 1 To $aSections[0]
        $sDefault = IniRead($sFilename, $aSections[$i], 'Default', '0')

        If $sDefault = '1' Then
            $sProfilePath = IniRead($sFilename, $aSections[$i], "Path", "")
            ExitLoop
        EndIf
    Next
EndIf

ConsoleWrite($sProfilesPath & $sProfilePath & @CRLF)

 

Link to comment
Share on other sites

First it tells me to close the firefox opened, then it gives an error:

 

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\egual\Desktop\firefox.au3" /UserParams    
+>15:02:53 Starting AutoIt3Wrapper (19.1127.1402.0} from:SciTE.exe (4.2.0.0)  Keyboard:00000816  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0816)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\myname\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\egual\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\myname\Desktop\firefox.au3
+>15:02:53 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\egual\Desktop\firefox.au3"    
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
_WD_IsLatestRelease: True
_WD_IsLatestRelease ==> Success
_WDStartup: OS: WIN_10 WIN32_NT 19041 
_WDStartup: AutoIt: 3.3.14.5
_WDStartup: WD.au3: 0.3.1.0 (Up to date)
_WDStartup: WinHTTP:    1.6.4.2
_WDStartup: Driver: C:\Users\egual\Downloads\geckodriver-v0.28.0-win64\geckodriver.exe
_WDStartup: Params: --log trace
_WDStartup: Port:   4444
__WD_Post: URL=HTTP://127.0.0.1:4444/session; $sData={"capabilities":{"alwaysMatch": {"moz:firefoxOptions": {"args": ["-profile", "C:/Users/egual/AppData/Roaming/Mozilla/Firefox/Profiles/rmmsyfrx.default"],"log": {"level": "trace"}}}}}
__WD_Post: StatusCode=500; ResponseText={"value":{"error":"unknown error","message":"Process unexpectedly closed with status 0","stacktrace"...
__WD_Post ==> Webdriver Exception: {"value":{"error":"unknown error","message":"Process unexpectedly closed with status 0","stacktrace":""}}
_WD_CreateSession: {"value":{"error":"unknown error","message":"Process unexpectedly closed with status 0","stacktrace":""}}
_WD_CreateSession ==> Webdriver Exception: HTTP status = 500

 

Link to comment
Share on other sites

the cmd shows this:

1610204575009   geckodriver     INFO    Listening on 127.0.0.1:4444
1610204575409   webdriver::server       DEBUG   -> POST /session {"capabilities":{"alwaysMatch": {"moz:firefoxOptions": {"args": ["-profile", "C:/Users/egual/AppData/Roaming/Mozilla/Firefox/Profiles/ryhsyfrx.default"],"log": {"level": "trace"}}}}}
1610204575419   mozrunner::runner       INFO    Running command: "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe" "--marionette" "-profile" "C:/Users/egual/AppData/Roaming/Mozilla/Firefox/Profiles/ryhsyfrx.default" "-foreground" "-no-remote"
1610204575419   geckodriver::marionette DEBUG   Waiting 60s to connect to browser on 127.0.0.1:59399
1610204598951   webdriver::server       DEBUG   <- 500 Internal Server Error {"value":{"error":"unknown error","message":"Process unexpectedly closed with status 0","stacktrace":""}}

 

Link to comment
Share on other sites

I have an webform that is kind of a list, as one starts writing the name and it appears, and one clicks enter, i have made this script:

 

local $author = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/div/div[1]/table/tbody/tr/td/div[2]/form/table/tbody/tr[8]/td[2]/div/span/span[1]/span/ul/li/input")
ConsoleWrite("_WD_FindElement author result: " & $author & @CRLF)
_WD_ElementAction($sSession, $author, 'value', "Dan Brown")
Send ("{ENTER}")

how does one simulate the enter of the keyboard the "send" don't work.

 

Link to comment
Share on other sites

I have already tried everything like:

_WD_Action($sSession, 'actions', '{"actions": [{"type": "key", "id": "keyboard", "actions": [{"type": "keyDown", "value": "\uE007"}]}]}')
_WD_ElementAction($sSession, $author, 'click')

none worked. i will try by using the list commands.

Link to comment
Share on other sites

You are missing the keyup part :

$sAction = '{"actions":[{"type": "key", "id": "keyboard_1", "actions": [{"type": "keyDown", "value": "\uE006"}, {"type": "keyUp", "value": "\uE006"}]}]}'

Try 6 and 7 (return and enter)

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...