Jump to content

Compiling an EdgeDriver Script - (Moved)


Recommended Posts

Hi all,

I've been slowly developing a script to use Edge to log into our EHR software in the office. It's been full of trials and tribulations for sure, and currently I'm running into issues with the compiled script not working on test computers. It works flawlessly when ran from SCiTE or from the .au3 file and the executable works on my own computer.

I was doing some testing just now with debugging and from what I could find it wasn't executing anything past the call to start Edge. Out of curiousity, I put the msedgedriver into the Include folder on that test computer and while it didn't run fully, the command box popped up for the driver but it didn't generate any logs. Much further than it had gone before but not quite where I need it.

I can post snippets of code if necessary but I wanted to see if anyone else has seen this behavior before. Not sure why the msedgedriver either isn't included in the executable or is broken inside after compiling.

Link to post
Share on other sites
  • Developers

Moved to the appropriate AutoIt General Help and Support forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

If you are using the Webdriver UDF (can't tell from the limited details in your post), then you could try logging into a file so that you can hopefully diagnose the issue. You would do something like --

_WD_Option('console', @ScriptDir & "\debuglog.txt"

This would go towards the beginning of your script, and you can control the level of detail by adjusting the value of $_WD_Debug.

You may want to check out the wiki, which outlines a similar issue in the troubleshooting section.

Link to post
Share on other sites

Hey Dan,

I am using the Webdriver UDF, but it's not able to generate that log on test computers with the executable. Here's my code below for you to look at, but I'm not sure that it's relevant. To reiterate, it's not able to launch Edge unless the computer running the executable has the msedgedriver in the AutoIT include folder (assuming it has AutoIT at all).

To reference the code snippet, I receive up to "Edge launch" with my hand-made debugger and nothing further. I also don't receive the msedge.log or the debuglog.txt that are set in the _WD_Options.

 

#include "wd_core.au3"
#include "wd_helper.au3"
#include <wd_capabilities.au3>
#include <AD.au3>


;Runs the Edge driver setup and opens a controlled session to EHR.
Local $sDesiredCapabilities, $sSession, $sElement
SetupEdge()

FileWrite("C:\senthelp\AutoIT Debug\debug.txt", "Driver setup")

_WD_Startup()
;_WD_ConsoleVisible()
$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "https://<EHR_website>")

FileWrite("C:\senthelp\AutoIT Debug\debug.txt", "Edge launch")

;Checks every .25 seconds for the Username and Password variables to tell when the page loads.
$oPageLoad = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="Enter user name"]')
For $var = 10000 to 0 Step -1
    If($oPageLoad) Then ExitLoop
    sleep(250)
    $oPageLoad = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="Enter user name"]')
Next

FileWrite("C:\senthelp\AutoIT Debug\debug.txt", "Page Check")

;Gets the computer description from Active Directory.
_AD_Open()
$sCompDescription = _AD_GetObjectAttribute(@ComputerName & "$", "Description")
_AD_Close()

FileWrite("C:\senthelp\AutoIT Debug\debug.txt", "AD get")

;Locates the username, password, and log on fields from the webpage.
Local $oUserName = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="Enter user name"]')
Local $oPassword = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="passwd"]')
Local $oSubmit = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="Log_On"]')


FileWrite("C:\senthelp\AutoIT Debug\debug.txt", "Field locate")

;Instantiates the login information to be entered on the site.
Local $sUserName = $sCompDescription
Local $sPassword = "<password>


;Enter Username and Password from variables above
_WD_SetElementValue($sSession, $oUserName, $sUserName)
_WD_SetElementValue($sSession, $oPassword, $sPassword)
_WD_ElementAction($sSession, $oSubmit, "click")


FileWrite("C:\senthelp\AutoIT Debug\debug.txt", "Login click")

;Looks for the "Detect citrix receiver" button on the next page to tell when it's loaded and then clicks.
$oDetectCitrix = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="protocolhandler-welcome-installButton"]')
For $var = 10000 to 0 Step -1
    If(_WD_ElementAction($sSession, $oDetectCitrix, 'click')) Then ExitLoop
    sleep(250)
    $oDetectCitrix = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="protocolhandler-welcome-installButton"]')
Next

FileWrite("C:\senthelp\AutoIT Debug\debug.txt", "Page load")

;Looks for the "Already installed" button on the next page to tell when it's loaded and then clicks.
$oInstalled = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="protocolhandler-detect-alreadyInstalledLink"]')
For $var = 10000 to 0 Step -1
    $oPageLoad_2 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//img[@alt="Production"]')
    If($oPageLoad_2) Then ExitLoop
    sleep(250)
    _WD_ElementAction($sSession, $oInstalled, 'click')
    $oInstalled = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="protocolhandler-detect-alreadyInstalledLink"]')
Next

FileWrite("C:\senthelp\AutoIT Debug\debug.txt", "Already installed")

;Looks for the EHR icon and clicks once loaded.
$oLaunchEpic = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//img[@alt="Production"]')
For $var = 10000 to 0 Step -1
    If(_WD_ElementAction($sSession, $oLaunchEpic, 'click')) Then ExitLoop
    sleep(250)
    $oLaunchEpic = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//img[@alt="Production"]')
 Next

FileWrite("C:\senthelp\AutoIT Debug\debug.txt", "Launch")

;Waits for the .ica file to download and open before closing Edge / the session.
Sleep(15000)
_WD_DeleteSession($sSession)
_WD_Shutdown()


;Sets the run parameters for Edge to be controlled by the Edge driver.
Func SetupEdge()
_WD_Option('Driver', 'C:\Program Files (x86)\AutoIt3\Include\msedgedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--verbose --Log-path="C:\senthelp\AutoIT Debug\msedge.log", --remote-debugging=false')
_WD_Option('console', "C:\senthelp\AutoIT Debug\debuglog.txt")


$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"binary": "' & StringReplace (@ProgramFilesDir, "\", "/") & '/Microsoft/Edge/Application/msedge.exe", "args": ["safe-mode=true", "start-maximized=true"], "excludeSwitches": [ "enable-automation"]}}}}'
EndFunc

 

Link to post
Share on other sites
52 minutes ago, Quorie said:

it's not able to launch Edge unless the computer running the executable has the msedgedriver in the AutoIT include folder

That is how you configured it with this line of code --

_WD_Option('Driver', 'C:\Program Files (x86)\AutoIt3\Include\msedgedriver.exe')

You would need to modify this line so that it uses a known good location or is user configurable.

Link to post
Share on other sites

I never actually paid attention to that since I just copied it over from examples. Is there a way to include that inside the executable or is it destined to be external?

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...