Jump to content

Recommended Posts

Posted

Hello dear users!

Please tell me how to make two working sessions in Firefox? Or two windows? You can drag the tab into a separate window...

In one window, for example, there is a YouTube player, in the second - work with mail.

PS: it seems like this can be done with Chrome, but I would really like to do it with Mozilla...

PS: I'm very sorry for my English!

 

#include 'MsgBoxConstants.au3'
#include 'wd_core.au3'
#include 'wd_helper.au3'
#include 'wd_capabilities.au3'


_WD_Option('Driver', 'geckodriver.exe')
_WD_Option('DriverParams', '--log trace')
_WD_Option('Port', 4444)

_WD_CapabilitiesStartup()
_WD_CapabilitiesAdd('args', '--headless')
_WD_CapabilitiesAdd('javascriptEnabled', True)
_WD_CapabilitiesAdd('nativeEvents', True)
_WD_CapabilitiesAdd('acceptInsecureCerts', True)

_WD_CapabilitiesAdd("alwaysMatch", "firefox")
_WD_CapabilitiesAdd("browserName", "firefox")

$sCapabilities = _WD_CapabilitiesGet()

_WD_Startup()

$sSessionA = _WD_CreateSession($sCapabilities)
$sSessionB = _WD_CreateSession($sCapabilities)

_WD_Navigate($sSessionA, "https://youtube.com")
_WD_Navigate($sSessionB, "https://gmail.com")

MsgBox(64,'',"The second session just doesn't work.")

_WD_DeleteSession($sSessionA)
_WD_DeleteSession($sSessionB)

_WD_Shutdown()

Is there any way to run geckodriver.exe with a different port? Can make a copy of geckodriver.exe, i.e. geckodriver2.exe, can use a different folder/location...

Posted (edited)

Hi @SEKOMD ๐Ÿ‘‹ ,

would it be enough to use two browser tabs instead? Or do you really need two instances (driver windows)?

Best regards
Sven

Edited by SOLVE-SMART

==> AutoIt related: ๐Ÿ”— GitHub, ๐Ÿ”— Discord Server, ๐Ÿ”— Cheat Sheet

  Reveal hidden contents
Posted
  On 5/17/2024 at 11:33 PM, Danp2 said:

Have you tried using _WD_Window with "new" for the subcommand?

Expand  

 

this COMPLETELY solves the problem, but I solved it differently - first we launch 2 windows, each with its own port (for example 2828 and 2829), then we connect to each window (if necessary) on the assigned port when the window was launched

I hope itโ€™s clear :) it wasnโ€™t easy for me to understand all this..))

 

This is just a sketch, an example of work so to speak:

 

#include <MsgBoxConstants.au3>
#include "wd_capabilities.au3"
#include "wd_helper.au3"

;_WD_Option('DriverClose', False)
;_WD_Option('DriverDetect', False)

;======================================================
;connecting to an EXISTING Firefox window - you only need to specify the port
;(it must be different - 2828, 2829, 2830, each Firefox-window has its own port)
If 1 = 1 Then

    ;the most important thing here is the PORT
    _WD_Option('Driver', 'geckodriver.exe')
    _WD_Option('DriverParams', '--log trace --connect-existing  --marionette-port 2828')
    _WD_Option('Port', 4444)

    _WD_Startup()
    $WD_SESSION = _WD_CreateSession()

    ;testing
    _WD_Navigate($WD_SESSION, "https://www.google.com")

    MsgBox(64,'','Ok?')

    ;_WD_DeleteSession($WD_SESSION)
    _WD_Shutdown()

Else
    ;======================================================
    ;launch a Firefox window with a specific port and exit
    _WD_Option('Driver', 'geckodriver.exe')
    _WD_Option('DriverParams', '--log trace --marionette-port 2828')
    _WD_Option('Port', 4444)

    _WD_Startup()

    _WD_CapabilitiesStartup()
    _WD_CapabilitiesAdd('alwaysMatch')
    _WD_CapabilitiesAdd('acceptInsecureCerts', True)
    _WD_CapabilitiesAdd('firstMatch', 'firefox')
    _WD_CapabilitiesAdd('pageLoadStrategy', 'none')

    $WD_SESSION = _WD_CreateSession(_WD_CapabilitiesGet())

    _WD_Navigate($WD_SESSION, "https://www.autoitscript.com/forum")

    ;_WD_DeleteSession($WD_SESSION)
    _WD_Shutdown()
EndIf

 

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