Jump to content

WebDriver UDF - Help & Support (IV)


Recommended Posts

hello guys,

Thx Danp2 for your answer. I succeeded to connect to an existing Firefox.

First, i launched it with WebDriver with this code

_WD_Option('Driver', $geckodriverPath)
_WD_Option('Port', 4444)
_WD_Option('DriverParams', '--log trace --marionette-port 2828')
WD_Startup()
$w_Session = _WD_CreateSession($FFCapabilities)
_WD_Navigate($w_Session, "www.google.com") 

//i do some things

_WD_Shutdown()

then i can launch another webdriver script with 

_WD_Option('Driver', $geckodriverPath)
_WD_Option('Port', 4444)
_WD_Option('DriverParams', '--log trace --marionette-port 2828 --connect-existing')
WD_Startup()
Local $WD_SESSION = _WD_CreateSession(Default)

//i do some things again on the same previously launched firefox instance and i'm happy

_WD_Shutdown()

an i can interact with the previously launched firefox windows. Everything is good.

but, then, i need to launch another instance of firefox without closing or "overwrite" the previously launched instance with -- marionnette-port 2828.

So i launch another webdriver function with 

_WD_Option('Driver', $geckodriverPath)
_WD_Option('Port', 4444)
WD_Startup()
$w_Session = _WD_CreateSession($FFCapabilities)
_WD_Navigate($w_Session, "www.qwant.com")
_WD_Shutdown()

but it seems to use the same firefox instance and instead of finally have 2 firefox open, i only have one. :(

usually, when i launch the code above, i have several firefox windows, but when i use --marionnette-port, it is like i'm stuck with an instance...

i surely missed something...but not pretty confident with WebDriver to say what...

Link to comment
Share on other sites

Can somebody please guide me to the usage of _WD_CDPExecuteCommand functions

_WD_CDPExecuteCommand($sSession, "Network.setBlockedURLs", '{"url":["google.com","facebook.com"]')

want to block a particular url.

This is possible through cdp . But i m getting error.

It would be great if someone can help me out with the same

Link to comment
Share on other sites

7 minutes ago, Danp2 said:

@n3wbie double check your brackets (looks like you are missing a closing }).

If that isn't the issue,  then provide more details on the error you received.

That isnt the error i changed url so typos

actual error

 

_WD_ExecuteCDPCommand: {"value":{"error":"invalid argument","message":"invalid argument: params not passed\n  (Session info: chrome=109.0.5414.120)","stacktrace":"Backtrace:\n\t(No symbol) [0x01546643]\n\t(No symbol) [0x014DBE21]\n\t(No symbol) [0x013DDA9D]\n\t(No symbol) [0x01451496]\n\t(No symbol) [0x0142FD7C]\n\t(No symbol) [0x01446B09]\n\t(No symbol) [0x0142FB76]\n\t(No symbol) [0x014049C1]\n\t(No symbol) [0x01405E5D]\n\tGetHandleVerifier [0x017BA142+2497106]\n\tGetHandleVerifier [0x017E85D3+2686691]\n\tGetHandleVerifier [0x017EBB9C+2700460]\n\tGetHandleVerifier [0x015F3B10+635936]\n\t(No symbol) [0x014E4A1F]\n\t(No symbol) [0x014EA418]\n\t(No symbol) [0x014EA505]\n\t(No symbol) [0x014F508B]\n\tBaseThreadInitThunk [0x766133AA+18]\n\tRtlInitializeExceptionChain [0x77C29F72+99]\n\tRtlInitializeExceptionChain [0x77C29F45+54]\n"}}

https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-setBlockedURLs

 

this is what i want to achieve

Edited by n3wbie
Link to comment
Share on other sites

@n3wbie The $oParams parameter needs to be an object. You probably need to do something like this --

Local $aURLs = ["google.com", "facebook.com"]
    Local $oParams = Json_ObjCreate()
    Json_ObjPut($oParams, 'urls', $aURLs)
    _WD_CDPExecuteCommand($sSession, "Network.setBlockedURLs", $oParams)

 

Link to comment
Share on other sites

16 hours ago, Danp2 said:

@n3wbie The $oParams parameter needs to be an object. You probably need to do something like this --

Local $aURLs = ["google.com", "facebook.com"]
    Local $oParams = Json_ObjCreate()
    Json_ObjPut($oParams, 'urls', $aURLs)
    _WD_CDPExecuteCommand($sSession, "Network.setBlockedURLs", $oParams)

 

Thanks .Its Working.

Link to comment
Share on other sites

31 minutes ago, Danp2 said:

@DoVinhTrung It would probably help if you could post a short reproducer because I'm not sure that I understand the issue. Are you simply wanting to update the value of this element? Have you tried using the $_WD_OPTION_Advanced style?

i try with _WD_SetElementValue($sSession, _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, ".font-weight-bold"), '100', $_WD_OPTION_Advanced)
but not update, only show value

Link to comment
Share on other sites

8 hours ago, Danp2 said:

@DoVinhTrung Clearly there is more to this web control than the input element that you've shown us. We can't help further without more context, such as --

  • URL for this or another website using this same web control
  • Framework or library (ie: jQuery, Angular, etc) being used

Here 
The Internet (the-internet.herokuapp.com)
and
The Internet (the-internet.herokuapp.com)

Link to comment
Share on other sites

On 7/11/2023 at 4:07 PM, Danp2 said:

@Fred93 There are some settings that you need to change in order to launch multiple instances of the webdriver / browser. I suggest that you review this prior thread.

thx for your answer

Sadly, i didn't manage to make it works. :(

to explain my issue, i made little script in order to simulate what i'm doing on my main.

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

if i keep pressing on the 2 first, everything is ok.

If i press on "existing window" one, it seems to "brake" even how the 2 first one works. In my mind (and what i tried to achieve), i completely set up WD before every launch and i kill it after. But i'm clearly wrong.

testWD.au3

Link to comment
Share on other sites

15 minutes ago, Danp2 said:

@DoVinhTrung FWIW, that site appears to use Angular. I won't be assisting further with this because it likely goes against this forum's rules.

Hope you are able to change your password before someone logs in and takes everything from you. :muttley:

can told me how to search word can run with my wweb run

 

Link to comment
Share on other sites

@Fred93 Add the following line near the top of launch_NormalMode --

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

Then modify that same line in launch_ExistingWindow by adding "--connect-existing" --

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

Now retest. 😉

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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