Jump to content

Recommended Posts

Posted (edited)
  On 7/17/2023 at 8:04 AM, Fred93 said:

2 with a "classic" launch (at least as i understand it...) and 2 with the "existing window" mode.

Expand  

https://www.autoitscript.com/wiki/WebDriver#FAQ

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

thx @Danp2 and @mLipok

i'm not sure i explained my problem correctly. In fact, i succeeded to attach to an existing firefox instance. (thanks to your examples)

i launch webdriver with

_WD_Option('DriverParams', '--log trace --marionette-port 2828')

then i navigate to my url, do some things. then shutdown the driver with WD_shutdown()

Next, i launch again with :

_WD_Option('DriverParams', '--log trace --marionette-port 2828 --connect-existing')

and i can attach to my previously launched firefox instance. Everything is ok.

But from the moment i used --marionette-port 2828, there is no turning back. it will use always the same firefox instance, and i don't want that (i need to open several URL in several windows,

that's why in my previously post i made the testWD.au3.  If you click on the first 2 buttons, it will launch a firefox window as many times as you click on the button (for me, it's the "normal mode").

But when you click on "existing window mode" buttons, "normal mode" buttons don't work as expected... at least, as they used to before pressing "existing window" buttons.

 

 

Posted
  On 7/18/2023 at 6:37 AM, Fred93 said:

(i need to open several URL in several windows,

Expand  

but why not in one Browser but in separate TABS ?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)
  On 7/18/2023 at 9:35 AM, mLipok said:

but why not in one Browser but in separate TABS ?

Expand  

Because i open some web apps that require one browser each, without tabs. :(

Edited by Fred93
Posted (edited)
  On 7/18/2023 at 9:42 AM, Fred93 said:

some web apps that require one browser each, without tabs.

Expand  

I'm not an expert in creating website/portals, so I may be a layman here, but...
I have never encountered such a requirement.

I didn't even know this possibility existed.
Unless you mean clicking on the link opens a separate window.

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

I apologise in advance for my poor/bad English
I use google translate
please look at the attached file

Func _WD_GetTable with _HtmlTable2Array.au3    =    the data is acquired slowly

look at the example and the proposed solution

#include "wd_helper.au3"
#include "wd_capabilities.au3"
#include <_HtmlTable2Array.au3>
#include <IE.au3>
$_WD_DEBUG=$_WD_DEBUG_None
_WD_Option("errormsgbox", (@Compiled = 1))
_WD_Option("OutputDebug", (@Compiled = 1))
local $sCapabilities=SetupGecko("")
_WD_Startup()
local $_WD_CreateSession=_WD_CreateSession($sCapabilities)
local $url="file:///"&stringreplace(@scriptdir&"\table.html","\","/")
_WD_Navigate($_WD_CreateSession,$url)
_WD_LoadWait($_WD_CreateSession)
local $hTimer,$TimerDiff
$hTimer = TimerInit()
_WD_GetTable($_WD_CreateSession, "//table")
$TimerDiff=TimerDiff($hTimer)/1000
consolewrite(@crlf&"second : "&$TimerDiff&@crlf) ; ~ second : 23.6025399
;~ the data is acquired slowly

;~ do you like this solution?
$hTimer = TimerInit()
$Shell_Explorer_2_GUICreate=GUICreate("")
$oIE_se2=ObjCreate("Shell.Explorer.2")
GUICtrlCreateObj($oIE_se2,0,0)
_ienavigate($oIE_se2,"about:blank") 
local $html=_WD_ExecuteScript($_WD_CreateSession,'return document.documentElement.outerHTML',Default,Default, $_WD_JSON_Value)
_IEDocWriteHTML($oIE_se2,$html)
local $oTable=_IETableGetCollection($oIE_se2,0)
local $table=_IETableWriteToArray($oTable,true)
$TimerDiff=TimerDiff($hTimer)/1000
consolewrite(@crlf&"second : "&$TimerDiff&@crlf) ; ~ second : 0.4618603

_WD_DeleteSession($_WD_CreateSession)
_WD_Shutdown()

 

table.htmlFetching info...

To community goes all my regards and thanks

Posted
  On 7/18/2023 at 9:56 AM, mLipok said:

Unless you mean clicking on the link opens a separate window.

Expand  

yeah this is what i mean, it's not a "requirement". These app go on a separate window when i click on the link, u can't type in the adress bar, and in the past, with IE, i tried to launch them in tabs, but didn't work, some weirds session issues.

Posted (edited)
  On 7/18/2023 at 12:29 PM, Danp2 said:

@bdr529I tuoi risultati sono impressionanti, ma non mi piace particolarmente la soluzione a causa dell'inclusione di IE.au3. Ho notato che _WD_GetTable senza _HtmlTable2Array.au3 non riesce a recuperare il contenuto della tabella, quindi richiederà ulteriori ricerche per capire perché.

Expand  
$aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sBaseElement & "/tbody/tr[1]/td", "", True) ; Retrieve the number of table columns by checking the first table row

ko [1] /td
ok [1]/th or [2]/td

Edited by bdr529

To community goes all my regards and thanks

Posted

If you have a "basic" table that you want to extract quickly, you could probably use a bit of JavaScript to build a pipe and newline delimited table. See _WD_ExecuteScript and use something similar to this script:

// Accepts an HtmlElement currently for ease in testing. Modify to accept an XPath/Id?
function tableExport(table){
    var tbody = table.getElementsByTagName("tbody")[0];
    var text = "";
    // For each row
    for(let row of tbody.getElementsByTagName("tr")){
        // For each cell in the row
        for(let cell of row.getElementsByTagName("td")){
            // Note .innerText might not be what you want here, modify as needed
            text += cell.innerText + "|";
        }
        text = text.slice(0, -1) + '\n';
    }
    return text.slice(0, -1);
}

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

  Reveal hidden contents
Posted (edited)

For your information, the latest chrome.exe(115.0.5790.99) produces its version number as 114.0.5735.90 when querried with chrome.exe --version. I replaced my chromedriver.exe with 115.0.5790.98 anyway and it works. I did not test the compatibility with old version of chromedriver.exe.

Edit: I was confused. There is no problem.

Edited by CYCho
Posted

My confusion was caused by the change in the way Google packs chromedriver.exe in chromedriver_win32.zip file. In the new version, the zip file contains a folder(chromedriver-win32), mind the hyphen instead of underscore, wherein chromedriver.exe is packed. So unpacking the zip file will copy only the folder, requiring an additional step to copy the folder's contents to webdriver folder.

 

Posted (edited)

I found that upacking the zip file could be done by including the folder name after the name of zip file . I think wd_helper.au3 already covers this situation. I had problem because I was using an old code of mine to update the chromedriver.

$FilesInZip = $oShell.NameSpace($sZipFile & "\chromedriver-win32").items

 

Edited by CYCho
Posted

This morning I got on one computer an error updating Chromedriver. 
My Chrome has been updated to v115. and my Chromedriver is v114.

Look on https://chromedriver.chromium.org/downloads only Chromedriver v114 seems to be available.

For now other computers somehow don't have this problem (yet), but I dread having to update about 100 computers manually again 😂

image.png.1272007bf27f0fb2e16a27053139bbb3.png

 

My updater code is this:
 

$CDVer = GetCDVersion ()            ;Get Chromedriver version
$ChVer = GetChromeVersion ()        ;Get Chrome version

If $ChVer<>$CDVer Then
    $lResult = _WD_UpdateDriver('chrome', Default, Default, true )   ;Update Chromedriver
    $lErr = @error

    If $lResult=False Then
        $mText = "Chrome version: " & $ChVer & @CRLF & "Chromedriver version: " & $CDVer & @CRLF & @CRLF
        $mText = $mText & "Chrome Update Result: " & $lResult & @CRLF &  "Update Error: " & $lErr & @CRLF & @CRLF
        $mText = $mText & "Update fout: neem contact op met ICT afdeling."

        MsgBox (0,$sTitle,$mText)
        Exit
    EndIf
EndIf

 

 

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...