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

Spoiler

๐ŸŒย Au3Forums

๐ŸŽฒ AutoIt (en) Cheat Sheet

๐Ÿ“Š AutoIt limits/defaults

๐Ÿ’Ž Code Katas: [...] (comming soon)

๐ŸŽญ Collection of GitHub users with AutoIt projects

๐Ÿžย False-Positives

๐Ÿ”ฎย Me on GitHub

๐Ÿ’ฌย Opinion about new forum sub category

๐Ÿ“‘ย UDF wiki list

โœ‚ย VSCode-AutoItSnippets

๐Ÿ“‘ย WebDriver FAQs

๐Ÿ‘จโ€๐Ÿซย WebDriver Tutorial (coming soon)

Posted
On 5/17/2024 at 12:52 PM, SOLVE-SMART said:

Hi @SEKOMDย ๐Ÿ‘‹ ,

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

Best regards
Sven

unfortunately, you need exactly two separate windows

Posted
On 5/18/2024 at 2:33 AM, Danp2 said:

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

ย 

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