Jump to content

WebDriver and Admin rights


Recommended Posts

19 minutes ago, Erik_NJ said:
_WD_Startup: WinHTTP:   1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>)

Please grab the source from the link provided and replace your existing WinHttp.au3

Quote
__WD_Post ==> Webdriver Exception [10] : HTTP status = 500
_WD_CreateSession ==> Webdriver Exception [10]

You can get more detailed logging if you use $_WD_DEBUG = $_WD_DEBUG_Full so that we don't have to slog through 2MB of logs.

Also, since the session creation step failed there's no point in continuing to run the script beyond that point. You should as this line after the call to _WD_CreateSession --

If @error Then Exit

 

Edited by Danp2
Link to comment
Share on other sites

Hi,

I do have this line in my code:

If @error Then Exit SetError(1, @error)

Yes, I have the latest WinHTTP (in fact, I ran the script with 1.6.4.1 and 1.6.4.2 which is currently installed)

I've changed the DEBUG var as you suggested, this is the Scite Log

>"D:\Development\AutoIT_v33161\SciTe\..\AutoIt3.exe" "D:\Development\AutoIT_v33161\SciTe\AutoIt3Wrapper\AutoIt3Wrapper.au3" /test /run /prod /ErrorStdOut /in "D:\Development\AutoIT_v33161\_AutoIT-Apps\DEMO\WebTest.au3" /UserParams    
+>18:46:42 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0)  Keyboard:00000409  OS:WIN_10/2009  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => D:\Development\AutoIT_v33161\SciTe   UserDir => D:\Development\AutoIT_v33161\SciTe\AutoIt3Wrapper
- *** Compile in Test mode skipping Tidy; Au3Stripper; Resource updating and Versioning to speed up the process. ***
>Running AU3Check (3.3.16.1)  from:D:\Development\AutoIT_v33161  input:D:\Development\AutoIT_v33161\_AutoIT-Apps\DEMO\WebTest.au3
+>18:46:42 AU3Check ended.rc:0
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
->18:46:42 Script requires Admin rights while SciTE is at normal level -> Starting new AutoIt3Wrapper with #RequireAdmin to run the script.
+>18:46:44 Script started, waiting for output. (pid=9172)
-##>18:46:44 Restarted AutoIt3Wrapper with #RequireAdmin. (pid=9172)
- *** Compile in Test mode skipping Tidy; Au3Stripper; Resource updating and Versioning to speed up the process. ***
>Running:(3.3.16.1):D:\Development\AutoIT_v33161\autoit3_x64.exe "D:\Development\AutoIT_v33161\_AutoIT-Apps\DEMO\WebTest.au3"     
_WD_Option ==> Success [0] : Parameters:   Option=Driver   Value=D:\Development\AutoIT_v33161\_UDF\WebDriver\msedgedriver.exe
_WD_Option ==> Success [0] : Parameters:   Option=Port   Value=9515
_WD_Option ==> Success [0] : Parameters:   Option=DriverParams   Value=--log-path="D:\Development\AutoIT_v33161\_AutoIT-Apps\DEMO\MSEdge.log"
_WD_CapabilitiesStartup: #148 : > {"capabilities":"{}"} > IsObj = 1
_WD_CapabilitiesAdd: #177 :      $key = alwaysMatch     $value1 = msedge     $value2 = 
_WD_CapabilitiesAdd: #205 :  $_WD_NOTATION__MATCHTYPE = [capabilities][alwaysMatch] $_WD_NOTATION__SPECIFICVENDOR = ["ms:edgeOptions"]
_WD_CapabilitiesAdd ==> Success [0] : Successfully used [alwaysMatch]  with specified browser: msedge
_WD_CapabilitiesAdd: #177 :      $key = excludeSwitches     $value1 = enable-automation     $value2 = 
_WD_CapabilitiesAdd: #239 #275 :      $key = excludeSwitches     $value1 = enable-automation     $value2 =     $s_Notation = [capabilities][alwaysMatch]["ms:edgeOptions"]["excludeSwitches"][0]   <<<<  enable-automation
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd: #177 :      $key = acceptInsecureCerts     $value1 = True     $value2 = 
_WD_CapabilitiesAdd: #217 #275 :      $key = acceptInsecureCerts     $value1 = True     $value2 =     $s_Notation = [capabilities][alwaysMatch]["acceptInsecureCerts"]   <<<<  True
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd: #177 :      $key = args     $value1 = -inprivate     $value2 = 
_WD_CapabilitiesAdd: #239 #275 :      $key = args     $value1 = -inprivate     $value2 =     $s_Notation = [capabilities][alwaysMatch]["ms:edgeOptions"]["args"][0]   <<<<  -inprivate
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd: #177 :      $key = args     $value1 = user-data-dir     $value2 = C:\Stash\WD_Testing_Profile
_WD_CapabilitiesAdd: #247 #275 :      $key = args     $value1 = user-data-dir     $value2 = C:\Stash\WD_Testing_Profile    $s_Notation = [capabilities][alwaysMatch]["ms:edgeOptions"]["args"][1]   <<<<  user-data-dir=C:\Stash\WD_Testing_Profile
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_GetFreePort ==> Success [0] : 9515
_WD_IsLatestRelease ==> Success [0] : True
_WD_Startup: OS:    WIN_10 WIN32_NT 19045 
_WD_Startup: AutoIt:    3.3.16.1
_WD_Startup: Webdriver UDF: 0.13.0 (Up to date)
_WD_Startup: WinHTTP:   1.6.4.2
_WD_Startup: Driver:    D:\Development\AutoIT_v33161\_UDF\WebDriver\msedgedriver.exe (64 Bit)
_WD_Startup: Params:    --log-path="D:\Development\AutoIT_v33161\_AutoIT-Apps\DEMO\MSEdge.log"
_WD_Startup: Port:  9515
_WD_Startup: Command:   "D:\Development\AutoIT_v33161\_UDF\WebDriver\msedgedriver.exe" --log-path="D:\Development\AutoIT_v33161\_AutoIT-Apps\DEMO\MSEdge.log" 
_WD_Startup ==> Success [0]
__WD_Post: URL=HTTP://127.0.0.1:9515/session; Data={
    "capabilities":{
        "alwaysMatch":{
            "acceptInsecureCerts":true,
            "ms:edgeOptions":{
                "excludeSwitches":[
                    "enable-automation"
                ],
                "args":[
                    "-inprivate",
                    "user-data-dir=C:\\Stash\\WD_Testing_Profile"
                ]
            }
        }
    }
}
__WD_Post ==> Webdriver Exception [10] : HTTP status = 500 ResponseText={"value":{"error":"unknown error","message":"unknown error: Microsoft Edge failed to start: exited normally.\n  (unknown error: DevToolsActivePort file doesn't exist)\n  (The process started from msedge location C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe is no longer running, so msedgedriver is assuming that msedge has crashed.)","stacktrace":"Backtrace:\n\tGetHandleVerifier [0x00007FF6ED83D8C2+60274]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED7CE522+818882]\n\t(No symbol) [0x00007FF6ED45DFAE]\n\t(No symbol) [0x00007FF6ED4894B1]\n\t(No symbol) [0x00007FF6ED48440A]\n\t(No symbol) [0x00007FF6ED4C7341]\n\t(No symbol) [0x00007FF6ED4BF343]\n\t(No symbol) [0x00007FF6ED491796]\n\t(No symbol) [0x00007FF6ED490975]\n\t(No symbol) [0x00007FF6ED491F04]\n\tMicrosoft::Applications::Events::EventProperties::SetLevel [0x00007FF6ED6D2147+1592039]\n\tMicrosoft::Applications::Events::EventProperties::SetLevel [0x00007FF6ED57AC4D+185837]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED70F6B7+36951]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED7077C5+4453]\n\tMicrosoft::Applications::Events::ILogManager::DispatchEventBroadcast [0x00007FF6EDA0FB93+1320211]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED7D65DC+851836]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED7D2644+835556]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED7D279C+835900]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED7C8371+793873]\n\tBaseThreadInitThunk [0x00007FFA52247604+20]\n\tRtlUserThreadStart [0x00007FFA532026A1+33]\n"}}
_WD_CreateSession ==> Webdriver Exception [10]
__WD_Post: URL=HTTP://127.0.0.1:9515/session//url; Data={"url":"http://www.google.com"}
__WD_Post ==> Invalid session ID [16] : HTTP status = 404 ResponseText={"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tGetHandleVerifier [0x00007FF6ED83D8C2+60274]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED7CE522+818882]\n\t(No symbol) [0x00007FF6ED45DE16]\n\t(No symbol) [0x00007FF6ED49004D]\n\t(No symbol) [0x00007FF6ED4BF462]\n\t(No symbol) [0x00007FF6ED48F5A1]\n\t(No symbol) [0x00007FF6ED4BBA31]\n\t(No symbol) [0x00007FF6ED4BB33A]\n\t(No symbol) [0x00007FF6ED42DB20]\n\tMicrosoft::Applications::Events::EventProperties::SetLevel [0x00007FF6ED6D2147+1592039]\n\tMicrosoft::Applications::Events::EventProperties::SetLevel [0x00007FF6ED57AC4D+185837]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED70F6B7+36951]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED7077C5+4453]\n\tMicrosoft::Applications::Events::ILogManager::DispatchEventBroadcast [0x00007FF6EDA0FB93+1320211]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED7D65DC+851836]\n\t(No symbol) [0x00007FF6ED42C9D6]\n\tMicrosoft::Applications::Events::time_ticks_t::time_ticks_t [0x00007FF6EDA3F118+128456]\n\tBaseThreadInitThunk [0x00007FFA52247604+20]\n\tRtlUserThreadStart [0x00007FFA532026A1+33]\n"}}
_WD_Navigate ==> Invalid session ID [16] : Parameters:   URL=http://www.google.com
__WD_Post: URL=HTTP://127.0.0.1:9515/session//url; Data={"url":"http://www.duckduckgo.com"}
__WD_Post ==> Invalid session ID [16] : HTTP status = 404 ResponseText={"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tGetHandleVerifier [0x00007FF6ED83D8C2+60274]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED7CE522+818882]\n\t(No symbol) [0x00007FF6ED45DE16]\n\t(No symbol) [0x00007FF6ED49004D]\n\t(No symbol) [0x00007FF6ED4BF462]\n\t(No symbol) [0x00007FF6ED48F5A1]\n\t(No symbol) [0x00007FF6ED4BBA31]\n\t(No symbol) [0x00007FF6ED4BB33A]\n\t(No symbol) [0x00007FF6ED42DB20]\n\tMicrosoft::Applications::Events::EventProperties::SetLevel [0x00007FF6ED6D2147+1592039]\n\tMicrosoft::Applications::Events::EventProperties::SetLevel [0x00007FF6ED57AC4D+185837]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED70F6B7+36951]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED7077C5+4453]\n\tMicrosoft::Applications::Events::ILogManager::DispatchEventBroadcast [0x00007FF6EDA0FB93+1320211]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED7D65DC+851836]\n\t(No symbol) [0x00007FF6ED42C9D6]\n\tMicrosoft::Applications::Events::time_ticks_t::time_ticks_t [0x00007FF6EDA3F118+128456]\n\tBaseThreadInitThunk [0x00007FFA52247604+20]\n\tRtlUserThreadStart [0x00007FFA532026A1+33]\n"}}
_WD_Navigate ==> Invalid session ID [16] : Parameters:   URL=http://www.duckduckgo.com
__WD_Post: URL=HTTP://127.0.0.1:9515/session//url; Data={"url":"http://www.bing.com"}
__WD_Post ==> Invalid session ID [16] : HTTP status = 404 ResponseText={"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tGetHandleVerifier [0x00007FF6ED83D8C2+60274]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED7CE522+818882]\n\t(No symbol) [0x00007FF6ED45DE16]\n\t(No symbol) [0x00007FF6ED49004D]\n\t(No symbol) [0x00007FF6ED4BF462]\n\t(No symbol) [0x00007FF6ED48F5A1]\n\t(No symbol) [0x00007FF6ED4BBA31]\n\t(No symbol) [0x00007FF6ED4BB33A]\n\t(No symbol) [0x00007FF6ED42DB20]\n\tMicrosoft::Applications::Events::EventProperties::SetLevel [0x00007FF6ED6D2147+1592039]\n\tMicrosoft::Applications::Events::EventProperties::SetLevel [0x00007FF6ED57AC4D+185837]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED70F6B7+36951]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED7077C5+4453]\n\tMicrosoft::Applications::Events::ILogManager::DispatchEventBroadcast [0x00007FF6EDA0FB93+1320211]\n\tMicrosoft::Applications::Events::EventProperty::~EventProperty [0x00007FF6ED7D65DC+851836]\n\t(No symbol) [0x00007FF6ED42C9D6]\n\tMicrosoft::Applications::Events::time_ticks_t::time_ticks_t [0x00007FF6EDA3F118+128456]\n\tBaseThreadInitThunk [0x00007FFA52247604+20]\n\tRtlUserThreadStart [0x00007FFA532026A1+33]\n"}}
_WD_Navigate ==> Invalid session ID [16] : Parameters:   URL=http://www.bing.com
__WD_Delete: URL=HTTP://127.0.0.1:9515/session/
__WD_Delete ==> Success [0] : HTTP status = 200 ResponseText={"value":null}
_WD_DeleteSession ==> Success [0] : WebDriver session deleted
+>18:47:04 AutoIt3.exe ended.rc:0
+>18:47:04 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 22.85

The MSEDGE.log is still BIG (2MB)

Link to comment
Share on other sites

15 minutes ago, Erik_NJ said:

I do have this line in my code:

Well, it isn't working (something clearing @error?) or it's in the wrong location. Otherwise, it would exit when the session creation fails and you wouldn't see attempts to navigate.

Quote
"unknown error: Microsoft Edge failed to start: exited normally.\n  (unknown error: DevToolsActivePort file doesn't exist)

This is the same error as before, so it's like the file still can't be created. I just tried it using the suggested method, and it failed with the same error. It also fails when using C:\Temp\WD_Testing_Profile. I'm wondering if the profile must already exist if you use "user-data-dir". Does C:\Stash\WD_Testing_Profile point to an existing user profile?

Link to comment
Share on other sites

These errors only happen when running as ADMIN, and as you can see, I even changed the location of the profile, deleted it and run the project, same deal.

The project is nothing fancy just open the browser and navigate to 3 sites (as you can see in the logs), something is missing somewhere when elevated rights are used.

I really appreciate your help, AutoIT and this UDF are great and I'm always lucky finding bugs.

Link to comment
Share on other sites

I believe the issue resides with Edgedriver. I've opened an issue on their GH repo, so now we have to wait and see how they respond. I tested with Chrome, and it appears to be able to create a new profile at the location supplied in user-data-dir in both Admin and non-Admin modes. It seems like Edge has issues create a new profile in the user supplied directory. Try running your script as standard user to see if it can create the files for the user profile. Then rerun it as Admin and see if that works.

Link to comment
Share on other sites

1 minute ago, Danp2 said:

I believe the issue resides with Edgedriver. I've opened an issue on their GH repo, so now we have to wait and see how they respond. I tested with Chrome, and it appears to be able to create a new profile at the location supplied in user-data-dir in both Admin and non-Admin modes. It seems like Edge has issues create a new profile in the user supplied directory. Try running your script as standard user to see if it can create the files for the user profile. Then rerun it as Admin and see if that works.

I've done that and it fails as admin.

I agree, this is then an EdgeDriver problem, lucky me, since I need to write this app for Edge (the "official" browser at work)

Link to comment
Share on other sites

6 minutes ago, Danp2 said:

As a temporary workaround, you could try using Chromedriver in lieu of Edgedriver. 😉

You would need to point to the correct binary file so that Edge was launched instead of Chrome.

Yes, I was thinking on trying that.

Thanks a lot bud.

Link to comment
Share on other sites

33 minutes ago, Danp2 said:

I'm wondering if the profile must already exist if you use "user-data-dir". Does C:\Stash\WD_Testing_Profile point to an existing user profile?

I think parent dir must exist and you should have rights to write there.

I mean c:\stash must exist.

 

Btw FF require to exist entire path.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

16 minutes ago, mLipok said:

I think parent dir must exist and you should have rights to write there.

I mean c:\stash must exist.

 

Btw FF require to exist entire path.

The folder exists, no restrictions and if the folder doesn't exists, it gets created automatically.

Link to comment
Share on other sites

11 hours ago, Danp2 said:

I've opened an issue on their GH repo, so now we have to wait and see how they respond.

So, here's the response from MSFT --

Quote

Edge will not launch in administrator mode. This was an explicit decision where Edge diverges from Chrome for security reasons. The test will need to run unelevated for Edge to launch successfully.

@Erik_NJ Why won't your script work in non-elevated mode?

Link to comment
Share on other sites

6 hours ago, Danp2 said:

So, here's the response from MSFT --

@Erik_NJ Why won't your script work in non-elevated mode?

Oh well, thanks Microsoft.

The reason I need admin rights is because the app is for internal kiosks and some settings need to be manipulated on those PCs that require elevated permissions.

My company's "official" browser is Edge and that's why I'm going thru all this.

I hate "hacking" or "workarounding" since Chrome or Edge might change something and I'll end up with a ton of non-working systems, installing Chrome will not work because InfoSec in their INFINITE WISDOM will remove the app without notice since is not "approved."

I truly appreciate all the help, I've been using AutoIT for a while and I will continue using it, it's a great tool.

Thanks

Link to comment
Share on other sites

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