Jump to content

When using MSEdgeDriver.exe 1st user sees two browser windows while the 2nd user sees nothing


Boboyka
 Share

Go to solution Solved by SkysLastChance,

Recommended Posts

SciTE-Lite  
Version 3.5.4 

I have this code below. When you launch it, it launches good, but if anyone else on the same host launches the script, that person's browser jumps on your session.

 

#include <IE.au3>
#include <GUIConstantsEx.au3>
#include <file.au3>
#include <array.au3>
;#NoTrayIcon
; non standard UDF's
#include "wd_core.au3"
#include "wd_helper.au3"
#include "wd_capabilities.au3"

 

Local $sDesiredCapabilities, $sSession

SetupEdge()
;$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"binary": $browser, "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false}}}}'
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)
$citrix = _WD_Navigate($sSession, $citrixurl)

Func SetupEdge()
    _WD_Option('Driver', 'C:\Program Files (x86)\AutoIt3\Include\msedgedriver.exe')
    _WD_Option('Port', 9515)
    ;_WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\msedge.log"')
   $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"browserName": "msedge", "acceptInsecureCerts":true}}}'
     ;Local $sCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"excludeSwitches": [ "enable-automation"]}}}}'
    _WD_CapabilitiesStartup()
    _WD_CapabilitiesAdd('alwaysMatch', 'msedge')
    _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation')
    _WD_CapabilitiesDump(@ScriptLineNumber) ; dump current Capabilities setting to console - only for testing in this demo
    Local $sCapabilities = _WD_CapabilitiesGet()
    Return $sCapabilities
EndFunc   ;==>SetupEdge
 

 

I found this discussion but I think that was not resolved:

WebDriver UDF - Help & Support (II) - Page 45 - AutoIt General Help and Support - AutoIt Forums (autoitscript.com)

 

Thank you for any help.

Link to comment
Share on other sites

Thanks for response, @Danp2.

Yes exactly, two users are connected remotely with their own sessions. When the second launches the script, the browser session of that person goes to the first.

No, when I did what @stamyuka wrote, I'm getting ports table in separate window and that window just stays there. Looks like ConnView.au3 just launches that table instead of retrieving a data.

I've tried to copy msedgedriver.exe into user's home dir to launch it out from there but that didn't help either, although two users are launching it from their own driver file.

Also, when I use different port other than 9515, driver doesn't launch anything but shows 9515 in console.

Edited by Boboyka
Link to comment
Share on other sites

Here, this one below pops up ports table:

#include <IE.au3>
#include <GUIConstantsEx.au3>
#include <file.au3>
#include <array.au3>
;#NoTrayIcon
; non standard UDF's
#include "wd_core.au3"
#include "wd_helper.au3"
#include "wd_capabilities.au3"
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <ConnView.au3>

Local $sDesiredCapabilities, $sSession
;#cs;===========
Local $portEdge = 9515
 $aArray = _CV_GetExtendedTcpTable()
While 1
   $_Port = _ArrayFindAll($aArray, $portEdge, 0, 0, 0, 0, 2)
   If @error Then
      ExitLoop
   Else
      $portEdge = $portEdge + 1
   EndIf
WEnd

;#ce;=============
SetupEdge()

_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)
$citrix = _WD_Navigate($sSession, $citrixurl)

Func SetupEdge()
   ; Copy file to a user's directory
   $TempDir="C:\Users\"& @UserName
    FileCopy("C:\Program Files (x86)\AutoIt3\Include\msedgedriver.exe", $TempDir & "\EdgeDriver\", $FC_OVERWRITE + $FC_CREATEPATH)
    $EdgeExe = $TempDir & "\EdgeDriver\msedgedriver.exe"
    _WD_Option('Driver', $EdgeExe)
    _WD_Option('Port', $portEdge)
   $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"w3c": true, "useAutomationExtension": false, "args":["start-maximized", "disable-infobars"] }}}}'
    _WD_CapabilitiesStartup()
    _WD_CapabilitiesAdd('alwaysMatch', 'msedge')
    _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation')
    _WD_CapabilitiesAdd("acceptInsecureCerts", True)
    _WD_CapabilitiesAdd("useAutomationExtension", false) ;,"setExperimentalOption": {"useAutomationExtension", false} Somehow this key is not supported
    _WD_CapabilitiesAdd("args", "start-maximized")
    _WD_CapabilitiesAdd("args", "disable-infobars")
    _WD_CapabilitiesDump(@ScriptLineNumber) ; dump current Capabilities setting to console - only for testing in this demo
    Local $sCapabilities = _WD_CapabilitiesGet()
    Return $sCapabilities
EndFunc   ;==>SetupEdge

 

Link to comment
Share on other sites

  • Solution
Quote

No, when I did what @stamyuka wrote, I'm getting ports table in separate window and that window just stays there. Looks like ConnView.au3 just launches that table instead of retrieving a data.

You need to strip out the code you don't need in the #include <ConnView.au3>  

Quote

Also, when I use different port other than 9515, driver doesn't launch anything but shows 9515 in console.

You need to add. 

_WD_Option('DriverParams', '--verbose --port=' & $portEdge & ' --log-path="' & @ScriptDir & '\edge.log"')

Are you sure you don't want to run?

$sSession = _WD_CreateSession($sCapabilities)

Thoese are the ones you are returning however, you are creating the session with $sDesiredCapabilities

 

Couple other things that might help. Make sure you don't already have edge open befor you run the script. 

Rename the msedgedriver.exe for each user. I.E. (msedgedriver1.exe and msedgedriver2.exe) 

Edited by SkysLastChance

You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott

Link to comment
Share on other sites

Thank you for your answers.

21 hours ago, SkysLastChance said:

You need to strip out the code you don't need in the #include <ConnView.au3>  

You need to add. 

_WD_Option('DriverParams', '--verbose --port=' & $portEdge & ' --log-path="' & @ScriptDir & '\edge.log"')

This makes ports to work.

 

Are you sure you don't want to run?

$sSession = _WD_CreateSession($sCapabilities)

Thoese are the ones you are returning however, you are creating the session with $sDesiredCapabilities

I've tried to run with $sCapabilities but I couldn't make it work. What would be correct way to declare and put options in the function for $sCapabilities?

 

Couple other things that might help. Make sure you don't already have edge open befor you runt he script. 

 

Rename the msedgedriver.exe for each user. I.E. (msedgedriver1.exe and msedgedriver2.exe) 

I am copying edge driver with different name but now I get this error, which closes Edge after it launched. I think it is not related to code or options.

image.png.7b971c01ba7121629c26f44f05cd4a61.png

Link to comment
Share on other sites

I appreciate all of your responses. I didn't know, Edge was upgraded. When I looked at microsoft page, they have driver for Mac and not MS, lol. I'm going with lower patch version which works for me.

But still, I couldn't make it work with $sSession = _WD_CreateSession($sCapabilities). The driver is launching and shows successful, but no Edge browser comes out.

Although, Edge is launching only with $sSession = _WD_CreateSession($sDesiredCapabilities)

Thank you!

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