Jump to content

Script not working in RDP Closed session


MRAJ
 Share

Recommended Posts

I am using webdriver udf using IEDriverServer in msedge browser. Script is running fine in RDP session while logged in the server, but it  stopped working at login page when i run RDP in disconnected mode(not signed out just close the RDP session) scheduled in task scheduler

#include "wd_core.au3"
#include "wd_helper.au3"
#include "wd_capabilities.au3"




$_WD_DEBUG = $_WD_DEBUG_None ; Could also use $_WD_DEBUG_Error
$_WD_DEBUG = $_WD_DEBUG_Info ; Gives you the greatest level of details
_WD_Option('console', @ScriptDir & "\wdudf.log")

Local $sSession, $sElement,$sCapabilities,$bHeadless

Local $sCapabilities = SetupEdgeIEMode($bHeadless)

_WD_Startup()
 $sSession = _WD_CreateSession($sCapabilities)

_WD_Navigate($sSession, "URL")
   _WD_Window($sSession,"maximize")

_WD_LoadWait($sSession)



$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='unamebean']")

_WD_SetElementValue($sSession,$sElement,"username")
Sleep(2000)
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='pwdbean']")

_WD_SetElementValue($sSession,$sElement,"password")
Sleep(2000)
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@id='SubmitButton']")

_WD_ElementAction($sSession,$sElement,'click')


_WD_DeleteSession($sSession)
_WD_Shutdown()

Func SetupEdgeIEMode($bHeadless) ; this is for MS Edge IE Mode
    
    Local $sTimeStamp = @YEAR & '-' & @MON & '-' & @MDAY & '_' & @HOUR & @MIN & @SEC
    _WD_Option('Driver', 'IEDriverServer.exe') ;
    

    ;_WD_Option('Port', _WD_GetFreePort(5555, 5600))
    Local $iPort = _WD_GetFreePort(5555, 5600)
    If @error Then Return SetError(@error, @extended, 0)
    _WD_Option('Port', $iPort)
    _WD_Option('DriverParams', '-log-file="' & @ScriptDir & '\log\' & $sTimeStamp & '_WebDriver_EdgeIEMode.log" -log-level=INFO' & " -port=" & $_WD_PORT & " -host=127.0.0.1")
    _WD_CapabilitiesStartup()
    _WD_CapabilitiesAdd('alwaysMatch', 'msedgeie')
    _WD_CapabilitiesAdd('w3c', True)
    Local $sPath = _WD_GetBrowserPath("msedge.exe")
    If $sPath Then _WD_CapabilitiesAdd("ie.edgepath", $sPath)
    _WD_CapabilitiesAdd("ie.edgechromium", True)
    _WD_CapabilitiesAdd("ignoreProtectedModeSettings", True)
    _WD_CapabilitiesAdd("initialBrowserUrl", "URL")
    _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation')
If $bHeadless Then _WD_CapabilitiesAdd('args', '--headless' , '--allow-running-insecure-content')
    _WD_CapabilitiesDump(@ScriptLineNumber)
    Local $sCapabilities = _WD_CapabilitiesGet()
    Return $sCapabilities
EndFunc   ;==>SetupEdgeIEMode

. I am running other scripts too with msedge driver but no issue. It seems IEDriverserver.exe is not interacting with session in disconnect mode(not signed out just close the RDP session).

 

Logs:

 

_WD_Option ==> Success [0] : Parameters:   Option=console   Value=E:\AutoIT\AutoITScripts\wdudf.log
_WD_Option ==> Success [0] : Parameters:   Option=Driver   Value=E:\AutoIT\AutoITScripts\IEDriverServer.exe
_WD_GetFreePort ==> Success [0 / 5555] : Parameters:   MinPort=5555   MaxPort=5600
_WD_Option ==> Success [0] : Parameters:   Option=Port   Value=5555
_WD_Option ==> Success [0] : Parameters:   Option=DriverParams   Value=--port=5555 -host=127.0.0.1 -log-file="E:\AutoIT\AutoITScripts\log\2024-11-21_161001_WebDriver_EdgeIEMode.log" -log-level=INFO
_WD_CapabilitiesAdd ==> Success [0] : Successfully used [alwaysMatch]  with specified browser: msedgeie
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_GetBrowserPath ==> Success [0 / 3] : Parameters:    Browser=msedge
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesDump: JSON structure starts below: -1
{
    "capabilities":{
        "alwaysMatch":{
            "se:ieOptions":{
                "w3c":true,
                "ie.edgepath":"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe",
                "ie.edgechromium":true,
                "ignoreProtectedModeSettings":true,
                "initialBrowserUrl":"https:\/\/url.com",
                "excludeSwitches":[
                    "enable-automation"
                ]
            }
        }
    }
}
_WD_CapabilitiesDump: JSON structure ends above.
_WD_GetFreePort ==> Success [0 / 5555] : Parameters:   MinPort=5555   MaxPort=Default
_WD_IsLatestRelease ==> Success [0] : True
_WD_Startup: OS:    WIN_2016 X64 17763 
_WD_Startup: AutoIt:    3.3.14.5
_WD_Startup: Webdriver UDF:    1.4.0 (Up to date)
_WD_Startup: WinHTTP:    1.6.4.2
_WD_Startup: Driver:    E:\AutoIT\AutoITScripts\IEDriverServer.exe (32 Bit)
_WD_Startup: Params:    --port=5555 -host=127.0.0.1 -log-file="E:\AutoIT\AutoITScripts\log\2024-11-21_161001_WebDriver_EdgeIEMode.log" -log-level=INFO
_WD_Startup: Port:    5555
_WD_Startup: Command:    "E:\AutoIT\AutoITScripts\IEDriverServer.exe" --port=5555 -host=127.0.0.1 -log-file="E:\AutoIT\AutoITScripts\log\2024-11-21_161001_WebDriver_EdgeIEMode.log" -log-level=INFO 
_WD_Startup ==> Success [0]
__WD_Post ==> Send / Recv error [6] : HTTP status = 0
_WD_CreateSession ==> Webdriver Exception [10]
__WD_Post ==> Unknown Command [18] : HTTP status = 404
_WD_FindElement ==> Unknown Command [18] : Parameters:   Strategy=xpath   Selector=//input[@id='unamebean']   StartNodeID=Default   Multiple=Default   ShadowRoot=Default
__WD_Get ==> Invalid session ID [16] : HTTP status = 404

Edited by MRAJ
Link to comment
Share on other sites

  • MRAJ changed the title to Script not working in RDP Closed session

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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