Jump to content

WebDriver UDF (W3C compliant version) - 2024/02/19


Danp2
 Share

Recommended Posts

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

Link to comment
Share on other sites

  • 3 weeks later...

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?

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

13 hours ago, 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.

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

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

On 4/20/2024 at 8:08 AM, laohacbancho37 said:

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

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

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

14 hours ago, 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

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
Link to comment
Share on other sites

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:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

On 4/23/2024 at 1:52 PM, mLipok said:

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
Link to comment
Share on other sites

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.

Spoiler
_WD_Navigate($sSession, "https://www.aviasales.ru/search/MCX1005NSK1")
    
    $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[contains(@data-test-id,'ticket-preview')]", '', True)
    If @Error = $_WD_ERROR_Success Then
        _ArrayDisplay($aElements, "Found Elements");it is ticket-preview
        For $i = 1 To UBound($aElements)
            $sValue = _WD_ElementAction($sSession, $aElements[$i - 1], "TEXT") ;it is text ticket-preview
            ConsoleWrite("$sValue = " & $sValue & @CRLF)
            
            $aElements_img = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//img [contains(@alt,'')]", '', True)
            _ArrayDisplay($aElements_img, "Found Elements_img");it is img ticket-preview
            For $j = 1 To UBound($aElements)
                $sValue1 = _WD_ElementAction($sSession, $aElements[$j - 1], "COMPUTEDLABEL") ;it is img ticket-preview
                ConsoleWrite("$sValue1 = " & $sValue1 & @CRLF)
            Next
        Next
    EndIf

2024-04-30_01h50_15.png.13591de6900bd6777d3050ed82b30750.png

Edited by SlavaS
add spoiler
Link to comment
Share on other sites

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

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

16 hours ago, SOLVE-SMART said:

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

/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:

Spoiler

2024-04-30_14h40_09.png.d2273abd33436490e9645206d32c5587.png2024-04-30_14h39_51.png.00c42dfc113736e3debec28140e7023f.png

Spoiler

<div class="s__xKtg4fAwICoYLzMUUBbr" data-test-id="ticket-preview"><div class="s__sKkvfJDIxRicM2rUUvFJ s__lleIiTmrq4X6cRWnmmEX"></div><div class="s__sKkvfJDIxRicM2rUUvFJ s__udxMJ8Cs9j0M_okGwvjS"><div class="s__fQedSoOntEndWYrxzwjN"><div class="s__sKkvfJDIxRicM2rUUvFJ"><div class="s__LFCEUVt95j7o8KHhg4_u s__rkxHGR99g7N6rg1wEzm8 s__wfLcPf6IF1Ayy7uJmdtH" data-test-id="text"><span class="s__wRhMOEwg2Ub7G1CotYcY" data-test-id="price">28 540 <span data-test-id="currency-sign" data-font-type="default" class="s__jAGK8batsh84RnnsPw6y">₽</span></span></div></div><div class="s__sKkvfJDIxRicM2rUUvFJ s__WfM5xsKUqHLdG0K4HE1X"></div><div class="s__sKkvfJDIxRicM2rUUvFJ"><div><label class="s__kZHw5ey1Nfdd1VoYQwfR s__EtwyvINuqRJVkBWwRkoI s__YYvvEic6_RvNnTO5etJ_ s__VfXtY64h2BGfJVEwLcwQ" data-test-id="switch"><input type="checkbox"><div class="s__vuzArb9RgGcgS__62pdP"><div class="s__ZsJorCPi_c9EkmaJ6Xms"><div class="s__SEseVRJI74LKH0_AGK1T s__xjysp1u5bYkOnjeY9MiA" data-test-id="text">Багаж</div><div class="s__VWGMQkNvXAk6vfgXhnEX s__ShYzKW_6zESUNc6duu4d s__vhKPNBRC_ke6FMt6cPgz" data-test-id="text">+ <span class="s__wRhMOEwg2Ub7G1CotYcY">10 216 <span data-test-id="currency-sign" data-font-type="default" class="s__jAGK8batsh84RnnsPw6y">₽</span></span></div></div></div><span class="s__ovxVR60WJIHdGKbLl0dA"></span></label></div></div><div class="s__sKkvfJDIxRicM2rUUvFJ"><div class="s__I_K0MtJ5bphxBz97WWNz"><button class="s__pYAhaCkOP9mPTxKVg5Qi s__cQ6neS4ccCunOu9Ydn0k s__tkvB9amX28GXeWxPcrad s__eEClvAD7BnPrQbwBW5zC s__p0epgEYgBbKyjc8MfJPw s__DW0Ga5H1qU_RvVpVSZj_" type="button" data-test-id="button"><div class="s__aS2HYDDDnUmns3X445R4 s__KSz0u_cE3hx7jl7_Dv8z s__YQHxt19vOcGsOro8j0pF" data-test-id="text">Выбрать билет</div></button></div></div><div class="s__sKkvfJDIxRicM2rUUvFJ"><div class="s__VWGMQkNvXAk6vfgXhnEX s__ShYzKW_6zESUNc6duu4d s__ho_GdpGpv6rkyZZnjpia" data-test-id="text">Остался 1&nbsp;билет по&nbsp;этой цене</div></div><div class="s__sKkvfJDIxRicM2rUUvFJ"></div></div></div><div class="s__cZfj3WT5CW4UmwF6rXOA"><div class="s__nMsql62Pl64va7MeHELw"><div class="s__sKkvfJDIxRicM2rUUvFJ s__wIMHVhBGXRzxucAUKFZS"><div class="s__Z7WNzSDK1pr1ZnxmfqAx"><div class="s__iLii9nj713he1PD8WMQ9"><div class="s__y2RUiTn4iZJEuSqgP9QL s__ph6oNsXRAWid72DFDugP s__kwrgpbfZ8sYHHD831gxw s__IfNnlCoxL4fHuW2lW3Xl"><img alt="Norwegian Air Shuttle" src="//img.avs.io/pics/al_square/DY@avif?rs=fit:64:64"></div><div class="s__y2RUiTn4iZJEuSqgP9QL s__ph6oNsXRAWid72DFDugP s__kwrgpbfZ8sYHHD831gxw s__IfNnlCoxL4fHuW2lW3Xl"><img alt="Ред Вингс" src="//img.avs.io/pics/al_square/WZ@avif?rs=fit:64:64"></div><div class="s__y2RUiTn4iZJEuSqgP9QL s__ph6oNsXRAWid72DFDugP s__kwrgpbfZ8sYHHD831gxw s__IfNnlCoxL4fHuW2lW3Xl"><img alt="Уральские авиалинии" src="//img.avs.io/pics/al_square/U6@avif?rs=fit:64:64"></div></div></div></div><div class="s__sKkvfJDIxRicM2rUUvFJ s__Q69bunrDCcM8Rjxpcv8O"><ul class="s__FLEEU2KjFS7d63xLsofM"><li class="s___FCv2ZcP9etfecK5PJJ6"><div class="s__EoYNtscQzakKX3qGdh4k s__swggHgqZlDREZQmjFxHV type_icon s__y9yqJ_Bihas4Ryxa1e5M"><svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="currentColor" aria-hidden="true" class="s__Eejxt9VIbDxxf2oNIKGW s__afbsrZkmCTK0oyB2F_iT" data-test-id="icon" style="display: inline-block;"><path clip-rule="evenodd" d="M18.214 15.014c-.422.091-.86.139-1.31.139-3.364 0-6.09-2.687-6.09-6.002 0-1.099.3-2.13.824-3.016-2.734.591-4.78 2.991-4.78 5.863 0 3.315 2.727 6.002 6.09 6.002 2.248 0 4.211-1.2 5.267-2.986z"></path></svg></div></li><li class="s___FCv2ZcP9etfecK5PJJ6"><div class="s__EoYNtscQzakKX3qGdh4k s__swggHgqZlDREZQmjFxHV type_icon s__y9yqJ_Bihas4Ryxa1e5M"><svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="currentColor" aria-hidden="true" class="s__Eejxt9VIbDxxf2oNIKGW s__afbsrZkmCTK0oyB2F_iT" data-test-id="icon" style="display: inline-block;"><path clip-rule="evenodd" d="M8 6v3.9h.007L8 9.906l2.667 2.594L8 15.1l.007.007H8V19h8v-3.893h-.007L16 15.1l-2.667-2.6L16 9.906l-.007-.006H16V6H8zm7.013 9.667V18H9v-2.333L12.007 13l3.006 2.667zM15 7H9v1h6V7z"></path></svg></div></li></ul></div><div class="s__sKkvfJDIxRicM2rUUvFJ s__UOs_z17igaYSqiGEgtHu"><div class="s__lPu2GhhyKCJx16JOSU5i"><button class="s__yqnlLVrbf93m9U6IyVAm"><svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="icon" data-test-id="icon" style="display: inline-block;"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 2.5a2 2 0 0 0-1.951 1.558A4.801 4.801 0 0 0 6 8.8v3.325l-.202.089A3 3 0 0 0 4 14.962V17h16v-2.038a3 3 0 0 0-1.797-2.748L18 12.125V8.8a4.801 4.801 0 0 0-4.049-4.742A2 2 0 0 0 12 2.5Zm4 10.933 1.4.613a1 1 0 0 1 .6.916V15H6v-.038a1 1 0 0 1 .6-.916l1.4-.613V8.8A2.8 2.8 0 0 1 10.8 6h2.4A2.8 2.8 0 0 1 16 8.8v4.633Z"></path><path d="M11.95 21a2.5 2.5 0 0 1-2.45-2h4.9a2.5 2.5 0 0 1-2.45 2Z"></path></svg></button><button class="s__yqnlLVrbf93m9U6IyVAm"><svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="icon" data-test-id="icon" style="display: inline-block;"><path d="M12.5 2h-1L7 6.5 8.5 8 11 5.5V16h2V5.5L15.5 8 17 6.5 12.5 2Z"></path><path d="M7 12a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1h-1v-2h1a3 3 0 0 1 3 3v5a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3v-5a3 3 0 0 1 3-3h1v2H7Z"></path></svg></button></div></div></div><div class="s__sKkvfJDIxRicM2rUUvFJ s__OK2h9k1NDlJ14NIorXih"></div><div class="s__sKkvfJDIxRicM2rUUvFJ s__Fc5oTL8UVIBCXx8l9Awg"><div class="s__HYabv5g__SaNMYDB9me3"><div class="s__BDIGHLNzuwIHeViMbEXQ s__QHWszhZ7uLCUNiwjWbhz" data-test-id="origin-endpoint"><div class="s__JbhTXlovTPG3WUQSML7w s___Hzt0p8X_ooYzXLgQokd s__QHWszhZ7uLCUNiwjWbhz"><div class="s__JbhTXlovTPG3WUQSML7w"><span class="s__FVoTcD1TH6rgNduZuYgA s__oXVxdY01BRdRDR1BPVh_ s__DhnUWRq_dnfbyy1pfoX2 s__sNYAKy6VBDAUbuW4TLqO" data-test-id="text">16:00</span></div></div><div class="s__JbhTXlovTPG3WUQSML7w s__n98tCLTBGrvH5SQ0LkaX"><span class="s__SEseVRJI74LKH0_AGK1T s__xjysp1u5bYkOnjeY9MiA s__DhnUWRq_dnfbyy1pfoX2 s__JQTliknB1kZw3563Ls0z" data-test-id="text">Осло</span></div><div class="s__JbhTXlovTPG3WUQSML7w"><span class="s__SEseVRJI74LKH0_AGK1T s__xjysp1u5bYkOnjeY9MiA s__DhnUWRq_dnfbyy1pfoX2 s__JQTliknB1kZw3563Ls0z" data-test-id="text">5&nbsp;мая,&nbsp;вс</span></div></div><div class="s__orV9ARm2izN7AZNWmz6l" data-test-id="ticket-segment-route"><div class="s__hbeQrFp4p03CwgkNmJ6c s__kiUoVGYFF9v_hTXejtM9"><svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="s__fCbYMka_uizHjX4rpFaA s__s6yWXhc5Ti8P2LTBzAAJ" data-test-id="icon" style="display: inline-block;"><path fill-rule="evenodd" clip-rule="evenodd" d="m16.954 9.793-2.719 1.268c-2-.64-4.862-1.236-7.398-2.056l-1.201.55c1.32 1.029 3.135 2.33 4.52 3.408L7.439 14.23c-1.173-.248-2.418-.338-3.349-.532-.506-.106-.816.339-.338.71 2.256 1.759 3.159 2.469 3.159 2.469.392.305.875.497 1.343.283l12.445-5.803c.906-.46.871-1.106.64-1.629-.547-1.173-2.049-1.003-4.384.064Z"></path></svg><span class="s__M49wJn5hnHZTQXXGxIev s__X1d_7DIWbU7OVy_hESOO s__bPTvIoVic8_KpuMIQouB s__s6yWXhc5Ti8P2LTBzAAJ" data-test-id="text">OSL</span></div><span class="s__SEseVRJI74LKH0_AGK1T s__xjysp1u5bYkOnjeY9MiA s__Khbz2VzN7C970CDuunwZ" data-test-id="text">В пути: 1 д 1 ч 10 м</span><div class="s__JbhTXlovTPG3WUQSML7w s__u_4KTNZUyzv_5oJevKZn"><div class="s__bVGrPe8Lz0XeH2kcgdaX"><div class="s__AzRuCBvE2n4nd7vpliww s__A30xqXg5Uof7RtX0wyOa" style="flex-grow: 215;"></div><div class="s__kHbspHTbuxINsDYDESOK s__QpEbi7ThQBYwxJ_EZMbj" style="flex-grow: 755;"><div class="s__M49wJn5hnHZTQXXGxIev s__X1d_7DIWbU7OVy_hESOO s__AR3ZoET73nD1uxC03pIQ s__w0rO64b3tlEVLBooLSIc s__X9YHwYUyLQvu1obW1nlf" data-test-id="text">IST</div></div><div class="s__AzRuCBvE2n4nd7vpliww s__A30xqXg5Uof7RtX0wyOa" style="flex-grow: 130;"></div><div class="s__kHbspHTbuxINsDYDESOK s__QpEbi7ThQBYwxJ_EZMbj" style="flex-grow: 230;"><div class="s__M49wJn5hnHZTQXXGxIev s__X1d_7DIWbU7OVy_hESOO s__AR3ZoET73nD1uxC03pIQ s__w0rO64b3tlEVLBooLSIc s__X9YHwYUyLQvu1obW1nlf" data-test-id="text">MRV</div></div><div class="s__AzRuCBvE2n4nd7vpliww s__A30xqXg5Uof7RtX0wyOa" style="flex-grow: 180;"></div></div></div><div class="s__hbeQrFp4p03CwgkNmJ6c s__kiUoVGYFF9v_hTXejtM9"><svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="s__fCbYMka_uizHjX4rpFaA s__K32zZZBsSlqte4guthWt" data-test-id="icon" style="display: inline-block;"><path fill-rule="evenodd" clip-rule="evenodd" d="m16.109 14.02-2.719-1.268c-.795-1.945-2.178-4.52-3.18-6.99l-1.193-.567c.06 1.674.23 3.9.295 5.655l-2.72-1.268c-.564-1.058-1.295-2.069-1.744-2.907-.245-.456-.785-.408-.762.198.103 2.858.14 4.006.14 4.006.018.497.182.99.646 1.21l12.445 5.804c.935.398 1.407-.043 1.659-.557.547-1.173-.549-2.214-2.867-3.317Z"></path></svg><span class="s__M49wJn5hnHZTQXXGxIev s__X1d_7DIWbU7OVy_hESOO s__bPTvIoVic8_KpuMIQouB s__K32zZZBsSlqte4guthWt" data-test-id="text">DME</span></div></div><div class="s__BDIGHLNzuwIHeViMbEXQ s__m58V02G2itHH4IxKd1ci" data-test-id="destination-endpoint"><div class="s__JbhTXlovTPG3WUQSML7w s___Hzt0p8X_ooYzXLgQokd s__m58V02G2itHH4IxKd1ci"><div class="s__JbhTXlovTPG3WUQSML7w"><span class="s__FVoTcD1TH6rgNduZuYgA s__oXVxdY01BRdRDR1BPVh_ s__DhnUWRq_dnfbyy1pfoX2 s__sNYAKy6VBDAUbuW4TLqO" data-test-id="text">18:10</span></div></div><div class="s__JbhTXlovTPG3WUQSML7w s__n98tCLTBGrvH5SQ0LkaX"><span class="s__SEseVRJI74LKH0_AGK1T s__xjysp1u5bYkOnjeY9MiA s__DhnUWRq_dnfbyy1pfoX2 s__JQTliknB1kZw3563Ls0z" data-test-id="text">Москва</span></div><div class="s__JbhTXlovTPG3WUQSML7w"><span class="s__SEseVRJI74LKH0_AGK1T s__xjysp1u5bYkOnjeY9MiA s__DhnUWRq_dnfbyy1pfoX2 s__JQTliknB1kZw3563Ls0z" data-test-id="text">6&nbsp;мая,&nbsp;пн</span></div></div></div></div></div></div>

Best regards

Slava

Edited by SlavaS
Added full element
Link to comment
Share on other sites

Spoiler
$aElements_img = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, './div[3]/div[1]/div[1]/div/div[1]/div/img', $aElements[$i - 1], True)
If @Error = $_WD_ERROR_Success Then
    For $j = 1 To UBound($aElements_img)
        $sValue1 = _WD_ElementAction($sSession, $aElements_img[$j - 1], "COMPUTEDLABEL") 
    Next
EndIf

 

Solved. It may be wrong of course. 😉

Thanks.

Link to comment
Share on other sites

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

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

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

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

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

×
×
  • Create New...