SEKOMD Posted May 17 Share Posted May 17 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... Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted May 17 Share Posted May 17 (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 May 17 by SOLVE-SMART Stay innovative! 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) Link to comment Share on other sites More sharing options...
Danp2 Posted May 17 Share Posted May 17 Have you tried using _WD_Window with "new" for the subcommand? SEKOMD 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
SEKOMD Posted May 19 Author Share Posted May 19 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 Link to comment Share on other sites More sharing options...
SEKOMD Posted May 19 Author Share Posted May 19 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: expandcollapse popup#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 mLipok 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now