Jump to content

Recommended Posts

Posted

No issue in my side. working correclty using Latest version of the UDF , WebDriverVersion: 123.0.6312.86 and getting console Hidden fine.

 

_Test()
Func _Test()
    MsgBox(0, @AutoItVersion, _WD_GetBrowserVersion("Chrome") & @CRLF & _WD_GetWebDriverVersion(@ScriptDir, "chromedriver.exe") & @CRLF & _WD_IsLatestRelease())

    Local $sCapabilities = SetupChrome(False)

    Local $iWebDriver_PID = _WD_Startup()
    _WD_ConsoleVisible(False)
    Local $sSession = _WD_CreateSession($sCapabilities)
    _WD_Navigate($sSession, 'https://www.google.com')
    _WD_LoadWait($sSession)
    MsgBox(0, "", "Show console after me")
    _WD_ConsoleVisible(True)
    MsgBox(0, "", "Exit After me")
    If $sSession Then _WD_DeleteSession($sSession)
    If $iWebDriver_PID Then _WD_Shutdown()
EndFunc   ;==>_Test

 

Saludos

  • 3 weeks later...
Posted

hi @Danp2 , I have a question that I hope you can help me with. Is it possible to use two Chrome profiles simultaneously with WebDriver? For example, I want to open Profile 1 to access youtube.com and Profile 2 to access facebook.com at the same time. Is this feasible? How can I differentiate between the two sessions?

 

Posted

Hi

Already tried a thorough search of the string "headers" all around the various webdriver related topics (previous 1 to 4 plus this one)

The only thing i found was this unanswered question:

Since i didn't find a specific webdriver function able to retrieve sent/received headers of the current active webdriver session (something corresponding to the "_WinHttpQueryHeaders" function in the winhttp library), i was wondering wether somebody came up with a workaround for that or not.

Thanks in advance

Posted (edited)

You can just use JavaScript:

const xhr = new XMLHttpRequest();
xhr.open("GET", "https://jsonplaceholder.typicode.com/posts/1");
xhr.send();
xhr.responseType = "json";
xhr.onload = () => {
  if (xhr.readyState == 4 && xhr.status == 200) {
    console.log(xhr.response);
  } else {
    console.log(`Error: ${xhr.status}`);
  }
};

https://www.freecodecamp.org/news/javascript-get-request-tutorial/

 

to initialize your own POST, GET, and any of type:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods

 

But I do not know a way to intercept headers from website within WebDriver .

 

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
  On 4/22/2024 at 7:26 AM, FrancoBordin said:

Since i didn't find a specific webdriver function able to retrieve sent/received headers of the current active webdriver session (something corresponding to the "_WinHttpQueryHeaders" function in the winhttp library), i was wondering wether somebody came up with a workaround for that or not.

Expand  

Hi @FrancoBordin, what do you want to achieve? Which header information are you interested in and why? Maybe there are other approaches then WebDriver 🤔 .

Best regards
Sven

==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet

  Reveal hidden contents
Posted
  On 4/20/2024 at 6:08 AM, laohacbancho37 said:

Is it possible to use two Chrome profiles simultaneously with WebDriver?

Expand  

Hi @laohacbancho37, could you please create a new Thread for your question? Because I believe there could be more suggestions, questions and so on around your question. This would be helpful to you and other people too, am sure 🤝 . Thanks.

Best regards
Sven

==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet

  Reveal hidden contents
Posted (edited)
  On 4/22/2024 at 8:28 PM, SOLVE-SMART said:

Hi @FrancoBordin, what do you want to achieve? Which header information are you interested in and why? Maybe there are other approaches then WebDriver 🤔 .

Best regards
Sven

Expand  

Thanks for the answer

I need to do that from within a webdriver session because the specific login process must be done interactively with a regular browser.

Only after that interactive action by the browser (controlled by webdriver), i need to retrieve some cookies entries as well as some response-headers entries to be subsequently used in winhttp calls.

I was obviously already able to retrieve cookies with "_WD_Cookies()", but not the response headers

Here's my code:

Local $sCapabilities = ""
If FileExists("geckodriver.exe") Then
    _WD_UpdateDriver('Firefox')
    $sCapabilities = Call(SetupGecko, False)
ElseIf FileExists("chromedriver.exe") Then
    _WD_UpdateDriver('Chrome')
    $sCapabilities = Call(SetupChrome, False)
ElseIf FileExists("msedgedriver.exe") Then
    _WD_UpdateDriver('MSEdge')
    $sCapabilities = Call(SetupEdge, False)
ElseIf FileExists("operadriver.exe") Then
    _WD_UpdateDriver('Opera')
    $sCapabilities = Call(SetupOpera, False)
EndIf

If not StringIsSpace($sCapabilities) Then
   Local $iWebDriver_PID = _WD_Startup()
   Local $sSession = _WD_CreateSession($sCapabilities)
   _WD_Window($sSession, "Maximize")
   _WD_Navigate($sSession, "http://www.somesite.com")
   If MsgBox($MB_OKCANCEL + $MB_SYSTEMMODAL + $MB_TOPMOST, "Awaiting confirmation", "Please click <OK> as soon as navigation is completed") = $idOk Then

      ;retrieving session cookies
      Local $cCookiesJson = _WD_Cookies($sSession, "GETALL")

      ;retrieving session last response headers (currently i'm unable to do this)
      ?????????

   Endif
   _WD_DeleteSession($sSession)
   _WD_Shutdown($iWebDriver_PID)
Endif

Thanks again in advance to anybody

Edited by FrancoBordin
correction
Posted

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 4/23/2024 at 11:52 AM, mLipok said:
Expand  

Hi there.

Yes, in particular something like the first link you posted, but looks like that isn't immediately obtainable from webdriver itself, due to their policy.

Quoted from there:

"Unfortunately, it doesn't look like you can do that with selenium alone in an automated fashion, as this is against their design principles for selenium. I don't agree that it is (since it supports getting cookie information -- what user actually goes through and parses through their cookies?).

I'm actually afraid that what i'm looking for is something out of the autoit udf's developer(s) control due to webdriver API limitations about that specific session info. Hope i'm wrong.

Thanks again

 

 

Edited by FrancoBordin
typos
Posted (edited)

Hello!
Please tell me how to get data from the resulting object in the cycle.
The text can be obtained, but with IMG problems.
For example, you need to get data <IMG alt = ’’> each ticket.

  Reveal hidden contents
Edited by SlavaS
add spoiler
Posted (edited)

Hi @SlavaS,

please ones again, which data do you want exactly?
Are you looking for all ALT attributes of images? Or do you want only texts?

Can you copy the DOM structure (the first yellow highlighted div and the childs) and paste it here?
Then we can use it directly in the browser to provide a better suggested XPath usage.

I ask for this, because I don't want to navigate to the given domain, to be honest.

Best regards
Sven

Edited by SOLVE-SMART

==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet

  Reveal hidden contents
Posted (edited)
  On 4/29/2024 at 7:05 PM, SOLVE-SMART said:

Can you copy the DOM structure (the first yellow highlighted div and the childs) and paste it here?

Expand  

/html/body/div[7]/div[1]/div/div[1]/div/div/div[2]/div[1]/div[2]/div[2]/div[1]/div/div/div[1]/div[2]/div/div

I need to get the texts of tickets from many tickets (I understand), but also all the texts of the attributes of the images of ALT belonging to each ticket. For example:

  Reveal hidden contents
  Reveal hidden contents

Best regards

Slava

Edited by SlavaS
Added full element
Posted
  Reveal hidden contents

Solved. It may be wrong of course. 😉

Thanks.

Posted (edited)

Hi @SlavaS,

I guess it could be done a bit more easy. For the case you want to get the alt="..." attribute text of the image tag, you can use this XPath:
'//div[@data-test-id="ticket-preview"]//img' ...

... also instead of 'computedlabel' you should be successful with this:

_WD_ElementAction($sSession, $sYourFoundImgElement, "attribute", "alt")

I hope this helps a bit 😇 .

Best regards
Sven

Edited by SOLVE-SMART

==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet

  Reveal hidden contents
Posted

Hi SOLVE-SMART

Only I need to get TEXT at the same time from tickets and Text attribute Alt Image Tag.

And with this option: '//div[@data-test-id="ticket-preview"]//img' ...
I get only Attribute Text of the Image Tag

Best regards

Slava

Posted

Hi @SlavaS,

yes of course you only get the texts of the image tags. This is intended because I only concentrated on your post with you solution:

image.thumb.png.c1ce2415f45f01c4f51bb1c87f559ead.png

Which means here you only get the alt attributes of the images tags too.
So I would suggest simply do two requests. One for the texts of the ticket cards and one for the alt tags.

Best regards
Sven

==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet

  Reveal hidden contents
  • 2 weeks later...
Posted (edited)

Hi folks 👋 , please consider to take part on the WebDriver poll which is regarding which driver do you automate.
Please have a quick look here and take part ==> this could help us to improve or harden the WebDriver project in the future 😇 .

Thanks, best regards
Sven

@SlavaS

Edited by SOLVE-SMART

==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet

  Reveal hidden contents
  • 3 months later...
Posted

I beg your pardon for my very poor english
I use google translate

 

table by index ( _IETableGetCollection)

Func _WD_GetTable($sSession, $sStrategy, $sSelector, $sRowsSelector = Default, $sColsSelector = Default,$index_table=0)
    Local Const $sFuncName = "_WD_GetTable"
    Local Const $sParameters = 'Parameters:   Strategy=' & $sStrategy & '   Selector=' & $sSelector & '   RowsSelector=' & $sRowsSelector & '   ColsSelector=' & $sColsSelector
    Local $sElement, $aTable = ''
    $_WD_HTTPRESULT = 0
    $_WD_HTTPRESPONSE = ''

    If $sRowsSelector = Default Then $sRowsSelector = "tr"
    If $sColsSelector = Default Then $sColsSelector = "td, th"

    ; Get the table element
    
    ; $sElement = _WD_FindElement($sSession, $sStrategy, $sSelector)
    $sElement = _WD_FindElement($sSession, $sStrategy, $sSelector,default, True)
    $ubound=ubound($sElement)-1
    if $ubound<$index_table then return seterror(-99)   
    
    
    Local $iErr = @error

    If $iErr = $_WD_ERROR_Success Then
        ; https://stackoverflow.com/questions/64842157
        Local $sScript = "return [...arguments[0].querySelectorAll(arguments[1])]" & _
                ".map(row => [...row.querySelectorAll(arguments[2])]" & _
                ".map(cell => cell.textContent.trim()));"   ; https://www.autoitscript.com/forum/topic/212230-whitespace-characters-showing-when-accessing-a-table-using-_wd_gettable/?do=findComment&comment=1536686

        ;Local $sArgs = __WD_JsonElement($sElement) & ', "' & $sRowsSelector & '", "' & $sColsSelector & '"'
        Local $sArgs = __WD_JsonElement($sElement[$index_table]) & ', "' & $sRowsSelector & '", "' & $sColsSelector & '"'
        
        Local $sResult = _WD_ExecuteScript($sSession, $sScript, $sArgs)
        $iErr = @error

        If $iErr = $_WD_ERROR_Success Then
            ; Extract target data from results and convert to array
            Local $sStr = StringMid($sResult, 10, StringLen($sResult) - 10)
            $aTable = __WD_Make2Array($sStr)
        EndIf
    EndIf

    Return SetError(__WD_Error($sFuncName, $iErr, $sParameters), 0, $aTable)
EndFunc   ;==>_WD_GetTable

example

local $aTableData=_WD_GetTable($sSession,$_WD_LOCATOR_ByXPath,"//table",default,default,1)

 

To community goes all my regards and thanks

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
×
×
  • Create New...