Jump to content

Getting collection like objects with WD similar to the IE UDFs


Recommended Posts

Hi,

I can not figure out if there is a way to deal with the web driver like there was with IE.
Back then there were some UDFs for the IE where I instantly got a link collection for example and could either search for a specific link or I could count elements on the website. Stuff like that. Now I can not find anything close to that.

What I need:
For an image upload I need to check the amount of images uploaded on a website. Earlier (with IE) I got an element collection which I "searched" with a for-loop.
Each element I compared the outer-html and finally got what I wanted. Now I can not manage that anymore.

Since collection UDFs seem not to exist anymore I tried a few things and it allways seems that I can only access a specific element on the website.
Even then the css-action on the _WD_ElementAction UDF shows nothing. I would not need the css anyway.

So here is what I have managed so far. It works ok and im good with it. I just thought maybe for the future there is another ways because it seems that I am running unneccessary km here. So first I am gettin the whole sourcecode with _WD_GetSource from the website. Then I use Stringreplace to replace a part html of the element which I want to count. I also use @extended because it can show the amount of the replaced elements. This way I konw exactly how many elements (pictures) have been uploaded yet.

I repeat that procedure until all pictures have been uploaded and the script can continue.

Like that:

Local $sPageSourceCode = _WD_GetSource($oEbayUpdate)
Local $sHtmlPictureCode = '<img src="https://i.ebayimg.com'
Local $sNewPageSourceCode = StringReplace($sPageSourceCode, $sHtmlPictureCode, "")
Local $iPictureReplacementCount = @extended
MsgBox(0, "Picturecount", "Pictures: " & $iPictureReplacementCount, 10000)

Very basic.
As I said, it works fine and I already have figured out a solution for me.
But if there is a more elegeant or simply a smarter way to accomplish that, I would like to know.

Thank you in advance!

Btw. I really like the WD UDFs. I did not want to sould ungreatfull. I just need some time to learn how to use the WD UDFs instead of the IE UDFs,

Edited by Sanja
Link to comment
Share on other sites

Thank you for the info.
No, I did not know about that. I would try that out as an alternative (just out of curiousity) but the elements do not have an id unfortunately. All I can find is a html tag and the link itself. No name, no id.

Lets say, the element(s) I am looking for do not have an ID. Is there another way to gather all elements of one kind?

Something similar to _IEImgGetCollection or _IELinkGetCollection

Since you mentioned _WD_FindElement I have seen that I also can choose a "starting node ID"

So I want to get the shown text from the <header> and I am trying to use _WD_FindElement.
However on the website this tag occurs twice and I need the "second" <header>. I have found an ID between those tags and use that as the start node ID.
But if I do that, I get no text at all. Am I using the start node id correctly or is the ID not referring to an html ID?
 

I tried to get the rendered text from the whole <div> which included the second header and it worked so I assume it has to work with the smaller part too, right?

Edited by Sanja
Link to comment
Share on other sites

18 minutes ago, Sanja said:

Something similar to _IEImgGetCollection or _IELinkGetCollection

Yes... Use $_WD_LOCATOR_ByTagName as the strategy and pass the tag name as the selector. For example --

; Locate multiple IMG elements
$aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByTagName, "img", Default, True)

 

19 minutes ago, Sanja said:

So I want to get the shown text from the <header> and I am trying to use _WD_FindElement.
However on the website this tag occurs twice and I need the "second" <header>.

Hard to say for sure with the limited information you've provided. I would think you could either --

  • Use $_WD_LOCATOR_ByTagName as discussed above and then just grab the 2nd found instance
  • Use the Div or another appropriate element as the starting node
Link to comment
Share on other sites

Yes regarding the <header> problem with the 2nd. <header> tag...I still do no know why it does not work.
I just looked for another element ID "above" the header tag and got the rendered text from that. Then I used StringinStr. Does not feel like a win but it works.

I almost have finished my script.
I have only one problem at the end. I hope it is OK to post my questions in this one thread instead of opening different ones.

Here is what I do:

I open a browser window and log in once.
Then I open a new tab and work only in that tab. That way the browser usually does not forget that I am already logged in.
After I finish the first iteration I would like to close the tab.
In the second iteration I open a new tab again (So I always have the same starting point).

For the first iteration there is no problem at all. Opening and closing tabs as often as I want works fine.
However in the second iteration the _WD_NewTab($sSession) does not work anymore for me.
I am using a while-loop. I also tried a for-to-loop. Both do not work in the second iteration.

Local $iCounter = 1

While 1
    MsgBox(0,"Open tab", "Iteration # " & $iCounter, 2)
    _WD_NewTab($sSession)
    MsgBox(0,"Close tab","", 2)
    _WD_Window($sSession, "close")
    Sleep(2000)
    $iCounter = $iCounter + 1
WEnd

What am I doing wrong?
The messages continue popping up and loops are counted but nothing happens with the tabs.

Btw. I know that I could just use the one initialy opened tab all the time and it would work.
I am just curious why this way does not work for me.

 

Edited by Sanja
Link to comment
Share on other sites

It was just an example. I need to open an additional tab at the beginning of my while loop and I close it again at the end of the loop. I want to do so for every iteration. It works only during the first iteration. That is my problem.

1 hour ago, Danp2 said:

Did you check the console output for any errors that might indicate the reason why your code isn't working as expected?

Yes, I did a test run with only 2 iterations of said expample. As far as I understand the program thinks that the windos does not exist anymore or something.
Sorry, I am not very familiar with the kind of information from the output panel yet. It is quite a lot of stuff, if one does not know what to look for.

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /test /run /prod /ErrorStdOut /in "C:\Users\aschu\OneDrive\Desktop\AutoIt_Testlauf\TabOpenClose.au3" /UserParams    
+>15:47:02 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0)  Keyboard:00000407  OS:WIN_10/2009  CPU:X64 OS:X64  Environment(Language:0407)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\aschu\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\aschu\AppData\Local\AutoIt v3\SciTE 
- *** Compile in Test mode skipping Tidy; Au3Stripper; Resource updating and Versioning to speed up the process. ***
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\aschu\OneDrive\Desktop\AutoIt_Testlauf\TabOpenClose.au3
+>15:47:03 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\aschu\OneDrive\Desktop\AutoIt_Testlauf\TabOpenClose.au3"    
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
_WD_IsLatestRelease: False
_WD_IsLatestRelease ==> Success
_WD_Startup: OS:    WIN_10 WIN32_NT 19042 
_WD_Startup: AutoIt:    3.3.14.5
_WD_Startup: WD.au3:    0.4.0.4 (Update available)
_WD_Startup: WinHTTP:   1.6.4.2
_WD_Startup: Driver:    chromedriver.exe
_WD_Startup: Params:    --verbose --log-path="C:\Users\aschu\OneDrive\Desktop\AutoIt_Testlauf\chrome.log"
_WD_Startup: Port:  9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"], "args":["--user-data-dir=C:\\Users\\aschu\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}
__WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"91.0....
_WD_CreateSession: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"91.0.4472.164","chrome":{"chromedriverVersion":"91.0.4472.19 (1bf021f248676a0b2ab3ee0561d83a59e424c23e-refs/branch-heads/4472@{#288})","userDataDir":"C:\\Users\\aschu\\AppData\\Local\\Google\\Chrome\\User Data\\"},"goog:chromeOptions":{"debuggerAddress":"localhost:57005"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:extension:largeBlob":true,"webauthn:virtualAuthenticators":true},"sessionId":"b670142409995c1e8057d9a0c1d0fa30"}}
__WD_Get: URL=HTTP://127.0.0.1:9515/session/b670142409995c1e8057d9a0c1d0fa30/window
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"CDwindow-05B4CB11C8D269819139493B89FE587C"}...
_WD_Window: {"value":"CDwindow-05B4CB11C8D269819139493B89FE587C"}...
__WD_Post: URL=HTTP://127.0.0.1:9515/session/b670142409995c1e8057d9a0c1d0fa30/window/new; $sData={"type":"tab"}
__WD_Post: StatusCode=200; ResponseText={"value":{"handle":"CDwindow-3AEE989DC93103101FBB5E8511534AF7","type":"tab"}}...
_WD_Window: {"value":{"handle":"CDwindow-3AEE989DC93103101FBB5E8511534AF7","type":"tab"}}...
__WD_Post: URL=HTTP://127.0.0.1:9515/session/b670142409995c1e8057d9a0c1d0fa30/window; $sData={"handle":"CDwindow-3AEE989DC93103101FBB5E8511534AF7"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Window: {"value":null}...
__WD_Delete: URL=HTTP://127.0.0.1:9515/session/b670142409995c1e8057d9a0c1d0fa30/window
__WD_Delete: StatusCode=200; ResponseText={"value":["CDwindow-05B4CB11C8D269819139493B89FE587C"]}...
_WD_Window: {"value":["CDwindow-05B4CB11C8D269819139493B89FE587C"]}...
__WD_Get: URL=HTTP://127.0.0.1:9515/session/b670142409995c1e8057d9a0c1d0fa30/window
__WD_Get: StatusCode=404; $iResult = 10; $sResponseText={"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unk...
__WD_Get ==> Webdriver Exception: {"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unknown error: web view not found\n  (Session info: chrome=91.0.4472.164)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00422DB3+2502067]\n\tOrdinal0 [0x003BC5B1+2082225]\n\tOrdinal0 [0x002C2498+1057944]\n\tOrdinal0 [0x002ABDD6+966102]\n\tOrdinal0 [0x003079F9+1341945]\n\tOrdinal0 [0x0030AF01+1355521]\n\tOrdinal0 [0x00305CF7+1334519]\n\tOrdinal0 [0x002E2174+1188212]\n\tOrdinal0 [0x002E3009+1191945]\n\tGetHandleVerifier [0x0059EC5C+1511084]\n\tGetHandleVerifier [0x00648522+2205554]\n\tGetHandleVerifier [0x004A3393+480739]\n\tGetHandleVerifier [0x004A2579+477129]\n\tOrdinal0 [0x003C1E5D+2104925]\n\tOrdinal0 [0x003C63F8+2122744]\n\tOrdinal0 [0x003C6537+2123063]\n\tOrdinal0 [0x003CEE53+2158163]\n\tBaseThreadInitThunk [0x7548FA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x76EF7A7E+286]\n\tRtlGetAppContainerNamedObjectPath [0x76EF7A4E+238]\n"}}
_WD_Window: {"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unk...
_WD_Window ==> Webdriver Exception: HTTP status = 404
__WD_Post: URL=HTTP://127.0.0.1:9515/session/b670142409995c1e8057d9a0c1d0fa30/window/new; $sData={"type":"tab"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unk...
__WD_Post ==> Webdriver Exception: {"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unknown error: web view not found\n  (Session info: chrome=91.0.4472.164)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00422DB3+2502067]\n\tOrdinal0 [0x003BC5B1+2082225]\n\tOrdinal0 [0x002C2498+1057944]\n\tOrdinal0 [0x002ABDD6+966102]\n\tOrdinal0 [0x003079F9+1341945]\n\tOrdinal0 [0x00314232+1393202]\n\tOrdinal0 [0x00305BEB+1334251]\n\tOrdinal0 [0x002E2174+1188212]\n\tOrdinal0 [0x002E3009+1191945]\n\tGetHandleVerifier [0x0059EC5C+1511084]\n\tGetHandleVerifier [0x00648522+2205554]\n\tGetHandleVerifier [0x004A3393+480739]\n\tGetHandleVerifier [0x004A2579+477129]\n\tOrdinal0 [0x003C1E5D+2104925]\n\tOrdinal0 [0x003C63F8+2122744]\n\tOrdinal0 [0x003C6537+2123063]\n\tOrdinal0 [0x003CEE53+2158163]\n\tBaseThreadInitThunk [0x7548FA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x76EF7A7E+286]\n\tRtlGetAppContainerNamedObjectPath [0x76EF7A4E+238]\n"}}
_WD_Window: {"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unk...
_WD_Window ==> Webdriver Exception: HTTP status = 404
__WD_Delete: URL=HTTP://127.0.0.1:9515/session/b670142409995c1e8057d9a0c1d0fa30/window
__WD_Delete: StatusCode=404; ResponseText={"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unk...
__WD_Delete ==> Webdriver Exception: {"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unknown error: web view not found\n  (Session info: chrome=91.0.4472.164)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00422DB3+2502067]\n\tOrdinal0 [0x003BC5B1+2082225]\n\tOrdinal0 [0x002C2498+1057944]\n\tOrdinal0 [0x002ABDD6+966102]\n\tOrdinal0 [0x003079F9+1341945]\n\tOrdinal0 [0x0030B1E7+1356263]\n\tOrdinal0 [0x00305CF7+1334519]\n\tOrdinal0 [0x002E2174+1188212]\n\tOrdinal0 [0x002E3009+1191945]\n\tGetHandleVerifier [0x0059EC5C+1511084]\n\tGetHandleVerifier [0x00648522+2205554]\n\tGetHandleVerifier [0x004A3393+480739]\n\tGetHandleVerifier [0x004A2579+477129]\n\tOrdinal0 [0x003C1E5D+2104925]\n\tOrdinal0 [0x003C63F8+2122744]\n\tOrdinal0 [0x003C6537+2123063]\n\tOrdinal0 [0x003CEE53+2158163]\n\tBaseThreadInitThunk [0x7548FA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x76EF7A7E+286]\n\tRtlGetAppContainerNamedObjectPath [0x76EF7A4E+238]\n"}}
_WD_Window: {"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unk...
_WD_Window ==> Webdriver Exception: HTTP status = 404
+>15:47:18 AutoIt3.exe ended.rc:0
+>15:47:18 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 16.54

 

Edited by Sanja
Link to comment
Share on other sites

After you close the tab, it is your responsibility to reestablish the original tab as the active "target". You need to do something like this --

; Save the current tab handle
$sTabHandle = _WD_Window($sSession, 'window')

; Perform your intermediate steps here

; Reactivate original tab 
_WD_Window($sSession, 'window', $sTabHandle)

 

Link to comment
Share on other sites

Hi, I am sorry but I need to ask again.

I unerstand what you were telling me. The script needs to know on which tab to focus again after the active tab was closed. Got it.

But I can not get the part with the handle right.
I tried it with a loop and even without a loop just as a sequence of commands. It does not work

As far as I see I do it like the UDF wants me to and also as you have described it.

Here is my test code (Ignore the MsgBoxes. Those are just for me to follow what the script is currentyl doing):

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.5
 Author:         Alexander Schulz
 Date:          Mai.1st.2018

 Script Function:
    Anzeigenaktualisierung

#ce ----------------------------------------------------------------------------

; Script Start

#include <AutoItConstants.au3>
#include <EditConstants.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <StaticConstants.au3>
#include "wd_core.au3"
#include "wd_helper.au3"
#include <WindowsConstants.au3>

HotKeySet("q", "Quit")

Local $sDesiredCapabilities
SetupChrome()
_WD_Startup()

$oSwitchTabs= _WD_CreateSession($sDesiredCapabilities)
Local $sFristTabHandle = _WD_Window($oSwitchTabs, "window")

Sleep(2000)
Local $iCounter = 1

While $iCounter <= 2
    Sleep(4000)
    _WD_Window($oSwitchTabs, "window", $sFristTabHandle )
    Local $hCurrentTabHandle = _WD_Window($oSwitchTabs, "window")
    MsgBox(0,"Handles BEFORE the tab", "Iteration # " & $iCounter & @CRLF & @CRLF & "First handle: " & $sFristTabHandle & @CRLF & @CRLF & "Current handle: " & $hCurrentTabHandle)
    _WD_NewTab($oSwitchTabs)
    $hCurrentTabHandle = _WD_Window($oSwitchTabs, "window")
    MsgBox(0,"Handles AFTER the tab", "Iteration # " & $iCounter & @CRLF & @CRLF & "First handle: " & $sFristTabHandle  & @CRLF & @CRLF & "Current handle: " & $hCurrentTabHandle)
    Sleep(1000)
    MsgBox(0,"Close Tab","", 2)
    _WD_Window($oSwitchTabs, "close")
    Sleep(1000)
    $iCounter = $iCounter + 1
WEnd


#cs
    Local $hCurrentTabHandle

    _WD_Window($oSwitchTabs, "window", $FristTabHandle )
    _WD_NewTab($oSwitchTabs)
    $hCurrentTabHandle = _WD_Window($oSwitchTabs, "window")
    MsgBox(0,"Handles AFTER the tab", "Iteration #1 " & @CRLF & @CRLF & "First handle: " & $FristTabHandle  & @CRLF & @CRLF & "Current handle: " & $hCurrentTabHandle)
    MsgBox(0,"Close Tab","", 2)
    _WD_Window($oSwitchTabs, "close")
    Sleep(1000)

    _WD_Window($oSwitchTabs, "window", $FristTabHandle )
    _WD_NewTab($oSwitchTabs)
    $hCurrentTabHandle = _WD_Window($oSwitchTabs, "window")
    MsgBox(0,"Handles AFTER the tab", "Iteration 2 " & @CRLF & @CRLF & "First handle: " & $FristTabHandle  & @CRLF & @CRLF & "Current handle: " & $hCurrentTabHandle)
    MsgBox(0,"Close Tab","", 2)
    _WD_Window($oSwitchTabs, "close")
    Sleep(1000)

    _WD_Window($oSwitchTabs, "window", $FristTabHandle )
    _WD_NewTab($oSwitchTabs)
    $hCurrentTabHandle = _WD_Window($oSwitchTabs, "window")
    MsgBox(0,"Handles AFTER the tab", "Iteration 3 " & @CRLF & @CRLF & "First handle: " & $FristTabHandle  & @CRLF & @CRLF & "Current handle: " & $hCurrentTabHandle)
    MsgBox(0,"Close Tab","", 2)
    _WD_Window($oSwitchTabs, "close")
    Sleep(1000)
#ce

Func SetupChrome()
    _WD_Option('Driver', 'chromedriver.exe')
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')

    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"], "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'


EndFunc   ;==>SetupChrome

Func Quit()
    MsgBox (0, "Exit", "")
   Exit
EndFunc

I still get only one iteration working with the tab. In the second iteration the script seems to have problems to find the "old" tab again.

Here is what the output tells me:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /test /run /prod /ErrorStdOut /in "C:\Users\aschu\OneDrive\Desktop\AutoIt_Testlauf\TabOpenClose.au3" /UserParams    
+>16:26:44 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0)  Keyboard:00000407  OS:WIN_10/2009  CPU:X64 OS:X64  Environment(Language:0407)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\aschu\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\aschu\AppData\Local\AutoIt v3\SciTE 
- *** Compile in Test mode skipping Tidy; Au3Stripper; Resource updating and Versioning to speed up the process. ***
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\aschu\OneDrive\Desktop\AutoIt_Testlauf\TabOpenClose.au3
+>16:26:44 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\aschu\OneDrive\Desktop\AutoIt_Testlauf\TabOpenClose.au3"    
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
_WD_IsLatestRelease: False
_WD_IsLatestRelease ==> Success
_WD_Startup: OS:    WIN_10 WIN32_NT 19042 
_WD_Startup: AutoIt:    3.3.14.5
_WD_Startup: WD.au3:    0.4.0.4 (Update available)
_WD_Startup: WinHTTP:   1.6.4.2
_WD_Startup: Driver:    chromedriver.exe
_WD_Startup: Params:    --verbose --log-path="C:\Users\aschu\OneDrive\Desktop\AutoIt_Testlauf\chrome.log"
_WD_Startup: Port:  9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"], "args":["--user-data-dir=C:\\Users\\aschu\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}
__WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"91.0....
_WD_CreateSession: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"91.0.4472.164","chrome":{"chromedriverVersion":"91.0.4472.19 (1bf021f248676a0b2ab3ee0561d83a59e424c23e-refs/branch-heads/4472@{#288})","userDataDir":"C:\\Users\\aschu\\AppData\\Local\\Google\\Chrome\\User Data\\"},"goog:chromeOptions":{"debuggerAddress":"localhost:61555"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:extension:largeBlob":true,"webauthn:virtualAuthenticators":true},"sessionId":"61e8d793d85af5777c11a2234696d44b"}}
__WD_Get: URL=HTTP://127.0.0.1:9515/session/61e8d793d85af5777c11a2234696d44b/window
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"CDwindow-F8579AEDA5A3105905EBAA98DDBAF959"}...
_WD_Window: {"value":"CDwindow-F8579AEDA5A3105905EBAA98DDBAF959"}...
__WD_Post: URL=HTTP://127.0.0.1:9515/session/61e8d793d85af5777c11a2234696d44b/window; $sData=CDwindow-F8579AEDA5A3105905EBAA98DDBAF959
__WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stack...
__WD_Post ==> Invalid argument: {"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stacktrace":"Backtrace:\n\tOrdinal0 [0x007B2DB3+2502067]\n\tOrdinal0 [0x0074C5B1+2082225]\n\tOrdinal0 [0x00652498+1057944]\n\tOrdinal0 [0x00693E4A+1326666]\n\tOrdinal0 [0x00693878+1325176]\n\tOrdinal0 [0x00634F1F+937759]\n\tOrdinal0 [0x00635426+939046]\n\tOrdinal0 [0x00635701+939777]\n\tGetHandleVerifier [0x0092EC5C+1511084]\n\tGetHandleVerifier [0x009D8522+2205554]\n\tGetHandleVerifier [0x00833393+480739]\n\tGetHandleVerifier [0x00832579+477129]\n\tOrdinal0 [0x00751E5D+2104925]\n\tOrdinal0 [0x00634CB5+937141]\n\tOrdinal0 [0x00634680+935552]\n\tGetHandleVerifier [0x009FE2AC+2360572]\n\tBaseThreadInitThunk [0x75FAFA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x77C87A7E+286]\n\tRtlGetAppContainerNamedObjectPath [0x77C87A4E+238]\n"}}
_WD_Window: {"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stack...
_WD_Window ==> Invalid argument: HTTP status = 400
__WD_Get: URL=HTTP://127.0.0.1:9515/session/61e8d793d85af5777c11a2234696d44b/window
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"CDwindow-F8579AEDA5A3105905EBAA98DDBAF959"}...
_WD_Window: {"value":"CDwindow-F8579AEDA5A3105905EBAA98DDBAF959"}...
__WD_Get: URL=HTTP://127.0.0.1:9515/session/61e8d793d85af5777c11a2234696d44b/window
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"CDwindow-F8579AEDA5A3105905EBAA98DDBAF959"}...
_WD_Window: {"value":"CDwindow-F8579AEDA5A3105905EBAA98DDBAF959"}...
__WD_Post: URL=HTTP://127.0.0.1:9515/session/61e8d793d85af5777c11a2234696d44b/window/new; $sData={"type":"tab"}
__WD_Post: StatusCode=200; ResponseText={"value":{"handle":"CDwindow-55C3DE3EE66FBA9643E2426D5069C579","type":"tab"}}...
_WD_Window: {"value":{"handle":"CDwindow-55C3DE3EE66FBA9643E2426D5069C579","type":"tab"}}...
__WD_Post: URL=HTTP://127.0.0.1:9515/session/61e8d793d85af5777c11a2234696d44b/window; $sData={"handle":"CDwindow-55C3DE3EE66FBA9643E2426D5069C579"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Window: {"value":null}...
__WD_Get: URL=HTTP://127.0.0.1:9515/session/61e8d793d85af5777c11a2234696d44b/window
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"CDwindow-55C3DE3EE66FBA9643E2426D5069C579"}...
_WD_Window: {"value":"CDwindow-55C3DE3EE66FBA9643E2426D5069C579"}...
__WD_Delete: URL=HTTP://127.0.0.1:9515/session/61e8d793d85af5777c11a2234696d44b/window
__WD_Delete: StatusCode=200; ResponseText={"value":["CDwindow-F8579AEDA5A3105905EBAA98DDBAF959"]}...
_WD_Window: {"value":["CDwindow-F8579AEDA5A3105905EBAA98DDBAF959"]}...
__WD_Post: URL=HTTP://127.0.0.1:9515/session/61e8d793d85af5777c11a2234696d44b/window; $sData=CDwindow-F8579AEDA5A3105905EBAA98DDBAF959
__WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stack...
__WD_Post ==> Invalid argument: {"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stacktrace":"Backtrace:\n\tOrdinal0 [0x007B2DB3+2502067]\n\tOrdinal0 [0x0074C5B1+2082225]\n\tOrdinal0 [0x00652498+1057944]\n\tOrdinal0 [0x00693E4A+1326666]\n\tOrdinal0 [0x00693878+1325176]\n\tOrdinal0 [0x00634F1F+937759]\n\tOrdinal0 [0x00635426+939046]\n\tOrdinal0 [0x00635701+939777]\n\tGetHandleVerifier [0x0092EC5C+1511084]\n\tGetHandleVerifier [0x009D8522+2205554]\n\tGetHandleVerifier [0x00833393+480739]\n\tGetHandleVerifier [0x00832579+477129]\n\tOrdinal0 [0x00751E5D+2104925]\n\tOrdinal0 [0x00634CB5+937141]\n\tOrdinal0 [0x00634680+935552]\n\tGetHandleVerifier [0x009FE2AC+2360572]\n\tBaseThreadInitThunk [0x75FAFA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x77C87A7E+286]\n\tRtlGetAppContainerNamedObjectPath [0x77C87A4E+238]\n"}}
_WD_Window: {"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stack...
_WD_Window ==> Invalid argument: HTTP status = 400
__WD_Get: URL=HTTP://127.0.0.1:9515/session/61e8d793d85af5777c11a2234696d44b/window
__WD_Get: StatusCode=404; $iResult = 10; $sResponseText={"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unk...
__WD_Get ==> Webdriver Exception: {"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unknown error: web view not found\n  (Session info: chrome=91.0.4472.164)","stacktrace":"Backtrace:\n\tOrdinal0 [0x007B2DB3+2502067]\n\tOrdinal0 [0x0074C5B1+2082225]\n\tOrdinal0 [0x00652498+1057944]\n\tOrdinal0 [0x0063BDD6+966102]\n\tOrdinal0 [0x006979F9+1341945]\n\tOrdinal0 [0x0069AF01+1355521]\n\tOrdinal0 [0x00695CF7+1334519]\n\tOrdinal0 [0x00672174+1188212]\n\tOrdinal0 [0x00673009+1191945]\n\tGetHandleVerifier [0x0092EC5C+1511084]\n\tGetHandleVerifier [0x009D8522+2205554]\n\tGetHandleVerifier [0x00833393+480739]\n\tGetHandleVerifier [0x00832579+477129]\n\tOrdinal0 [0x00751E5D+2104925]\n\tOrdinal0 [0x007563F8+2122744]\n\tOrdinal0 [0x00756537+2123063]\n\tOrdinal0 [0x0075EE53+2158163]\n\tBaseThreadInitThunk [0x75FAFA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x77C87A7E+286]\n\tRtlGetAppContainerNamedObjectPath [0x77C87A4E+238]\n"}}
_WD_Window: {"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unk...
_WD_Window ==> Webdriver Exception: HTTP status = 404
__WD_Get: URL=HTTP://127.0.0.1:9515/session/61e8d793d85af5777c11a2234696d44b/window
__WD_Get: StatusCode=404; $iResult = 10; $sResponseText={"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unk...
__WD_Get ==> Webdriver Exception: {"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unknown error: web view not found\n  (Session info: chrome=91.0.4472.164)","stacktrace":"Backtrace:\n\tOrdinal0 [0x007B2DB3+2502067]\n\tOrdinal0 [0x0074C5B1+2082225]\n\tOrdinal0 [0x00652498+1057944]\n\tOrdinal0 [0x0063BDD6+966102]\n\tOrdinal0 [0x006979F9+1341945]\n\tOrdinal0 [0x0069AF01+1355521]\n\tOrdinal0 [0x00695CF7+1334519]\n\tOrdinal0 [0x00672174+1188212]\n\tOrdinal0 [0x00673009+1191945]\n\tGetHandleVerifier [0x0092EC5C+1511084]\n\tGetHandleVerifier [0x009D8522+2205554]\n\tGetHandleVerifier [0x00833393+480739]\n\tGetHandleVerifier [0x00832579+477129]\n\tOrdinal0 [0x00751E5D+2104925]\n\tOrdinal0 [0x007563F8+2122744]\n\tOrdinal0 [0x00756537+2123063]\n\tOrdinal0 [0x0075EE53+2158163]\n\tBaseThreadInitThunk [0x75FAFA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x77C87A7E+286]\n\tRtlGetAppContainerNamedObjectPath [0x77C87A4E+238]\n"}}
_WD_Window: {"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unk...
_WD_Window ==> Webdriver Exception: HTTP status = 404
__WD_Post: URL=HTTP://127.0.0.1:9515/session/61e8d793d85af5777c11a2234696d44b/window/new; $sData={"type":"tab"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unk...
__WD_Post ==> Webdriver Exception: {"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unknown error: web view not found\n  (Session info: chrome=91.0.4472.164)","stacktrace":"Backtrace:\n\tOrdinal0 [0x007B2DB3+2502067]\n\tOrdinal0 [0x0074C5B1+2082225]\n\tOrdinal0 [0x00652498+1057944]\n\tOrdinal0 [0x0063BDD6+966102]\n\tOrdinal0 [0x006979F9+1341945]\n\tOrdinal0 [0x006A4232+1393202]\n\tOrdinal0 [0x00695BEB+1334251]\n\tOrdinal0 [0x00672174+1188212]\n\tOrdinal0 [0x00673009+1191945]\n\tGetHandleVerifier [0x0092EC5C+1511084]\n\tGetHandleVerifier [0x009D8522+2205554]\n\tGetHandleVerifier [0x00833393+480739]\n\tGetHandleVerifier [0x00832579+477129]\n\tOrdinal0 [0x00751E5D+2104925]\n\tOrdinal0 [0x007563F8+2122744]\n\tOrdinal0 [0x00756537+2123063]\n\tOrdinal0 [0x0075EE53+2158163]\n\tBaseThreadInitThunk [0x75FAFA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x77C87A7E+286]\n\tRtlGetAppContainerNamedObjectPath [0x77C87A4E+238]\n"}}
_WD_Window: {"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unk...
_WD_Window ==> Webdriver Exception: HTTP status = 404
__WD_Get: URL=HTTP://127.0.0.1:9515/session/61e8d793d85af5777c11a2234696d44b/window
__WD_Get: StatusCode=404; $iResult = 10; $sResponseText={"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unk...
__WD_Get ==> Webdriver Exception: {"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unknown error: web view not found\n  (Session info: chrome=91.0.4472.164)","stacktrace":"Backtrace:\n\tOrdinal0 [0x007B2DB3+2502067]\n\tOrdinal0 [0x0074C5B1+2082225]\n\tOrdinal0 [0x00652498+1057944]\n\tOrdinal0 [0x0063BDD6+966102]\n\tOrdinal0 [0x006979F9+1341945]\n\tOrdinal0 [0x0069AF01+1355521]\n\tOrdinal0 [0x00695CF7+1334519]\n\tOrdinal0 [0x00672174+1188212]\n\tOrdinal0 [0x00673009+1191945]\n\tGetHandleVerifier [0x0092EC5C+1511084]\n\tGetHandleVerifier [0x009D8522+2205554]\n\tGetHandleVerifier [0x00833393+480739]\n\tGetHandleVerifier [0x00832579+477129]\n\tOrdinal0 [0x00751E5D+2104925]\n\tOrdinal0 [0x007563F8+2122744]\n\tOrdinal0 [0x00756537+2123063]\n\tOrdinal0 [0x0075EE53+2158163]\n\tBaseThreadInitThunk [0x75FAFA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x77C87A7E+286]\n\tRtlGetAppContainerNamedObjectPath [0x77C87A4E+238]\n"}}
_WD_Window: {"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unk...
_WD_Window ==> Webdriver Exception: HTTP status = 404
__WD_Delete: URL=HTTP://127.0.0.1:9515/session/61e8d793d85af5777c11a2234696d44b/window
__WD_Delete: StatusCode=404; ResponseText={"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unk...
__WD_Delete ==> Webdriver Exception: {"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unknown error: web view not found\n  (Session info: chrome=91.0.4472.164)","stacktrace":"Backtrace:\n\tOrdinal0 [0x007B2DB3+2502067]\n\tOrdinal0 [0x0074C5B1+2082225]\n\tOrdinal0 [0x00652498+1057944]\n\tOrdinal0 [0x0063BDD6+966102]\n\tOrdinal0 [0x006979F9+1341945]\n\tOrdinal0 [0x0069B1E7+1356263]\n\tOrdinal0 [0x00695CF7+1334519]\n\tOrdinal0 [0x00672174+1188212]\n\tOrdinal0 [0x00673009+1191945]\n\tGetHandleVerifier [0x0092EC5C+1511084]\n\tGetHandleVerifier [0x009D8522+2205554]\n\tGetHandleVerifier [0x00833393+480739]\n\tGetHandleVerifier [0x00832579+477129]\n\tOrdinal0 [0x00751E5D+2104925]\n\tOrdinal0 [0x007563F8+2122744]\n\tOrdinal0 [0x00756537+2123063]\n\tOrdinal0 [0x0075EE53+2158163]\n\tBaseThreadInitThunk [0x75FAFA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x77C87A7E+286]\n\tRtlGetAppContainerNamedObjectPath [0x77C87A4E+238]\n"}}
_WD_Window: {"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unk...
_WD_Window ==> Webdriver Exception: HTTP status = 404
+>16:27:09 AutoIt3.exe ended.rc:0
+>16:27:09 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 25.22

Why does it tell me that the argument is invalid and that it is missing parameters?
What else does it need?
Syntax needs to be: _WD_Window($sSession, $sCommand, $sOption)

I have: _WD_Window($oSwitchTabs, "window", $FristTabHandle )
Why does the program detect an error?

Link to comment
Share on other sites

Ok... so I led you astray with the format of the command to restore the active tab. The one parameter needs to be formatted as a JSON string, so instead of this --

$sTabHandle = _WD_Window($sSession, 'window')

do this --

$sTabHandle =  '{"handle":"' & _WD_Window($sSession, "window") & '"}'

You can then pass this string to the subsequent call to _WD_Window to establish the new active tab.

P.S. This is something that you should have been able to figured out yourself by looking at the DemoWindows function in wd_demo.au3 😉

Link to comment
Share on other sites

Yes, that was it!

21 hours ago, Danp2 said:

P.S. This is something that you should have been able to figured out yourself by looking at the DemoWindows function in wd_demo.au3 😉

Maybe I would have found that solution if someone would have pointed me in that direction.
I have just now looked into the script and found the corresponding part.
But since I am currently almost unfamiliar wit java, I probalby would have looked everywhere else but the way the command was formatted.

I think the handle parameter that needed to be formated in java AND the code snipped in the beginning wich lets me use chorme without the warning about chrome beeing remotely controlled (look here) were the two things that I would not have figured out by myself.
I always wanted to learn a little bit java. Maybe this is a good reason start 😬

As for the rest I am rather sure that I would have figured it out sooner or later or I would simply keep using my "workarounds" wich also worked well enough.
Anyway, my script is finished now.

Thank you very much @Danp2 and @TheDcoder
I 100% would not be able to finish it without your help!

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