Jump to content

Recommended Posts

Posted

Hi everyone,

I would like to seek your help why sometimes the code or script I am running exits after _WD_FindElement successfully receives a correct element ID.

here is the code:

_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, '/html/body/div[4]/div/div[3]/div/div[3]/div/frame-router/iframe',2000,Default,Default,Default,Default)
    $iFrame_val = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath,'/html/body/div[4]/div/div[3]/div/div[3]/div/frame-router/iframe')
;~  ConsoleWrite("outside Frame")
    If $iFrame_val = "" Then
        ConsoleWrite("Inside the Frame - failed")
        do
            sleep(1000)
            _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, '/html/body/div[4]/div/div[3]/div/div[3]/div/frame-router/iframe',5000,Default,Default,Default,Default)
            local $iFrame_val = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '/html/body/div[4]/div/div[3]/div/div[3]/div/frame-router/iframe')
;~          ConsoleWrite("Frame not yet found")
        until $iFrame_val <> ""

 

Here is the logs on the console where you can see it exits.

__WD_Post: URL=HTTP://127.0.0.1:9515/session/77c1fb1b03252c172093747689f3a1b2/element; $sData={"using":"xpath","value":"/html/body/div[4]/div/div[3]/div/div[3]/div/frame-router/iframe"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"f.F1B254D330E71164B196301418F2A157.d.22B7D63D185732...
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"f.F1B254D330E71164B196301418F2A157.d.22B7D63D18573297274CDAACC74BAEAA.e.70"}}
_WD_WaitElement ==> Success
__WD_Post: URL=HTTP://127.0.0.1:9515/session/77c1fb1b03252c172093747689f3a1b2/element; $sData={"using":"xpath","value":"/html/body/div[4]/div/div[3]/div/div[3]/div/frame-router/iframe"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"f.F1B254D330E71164B196301418F2A157.d.22B7D63D185732...
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"f.F1B254D330E71164B196301418F2A157.d.22B7D63D18573297274CDAACC74BAEAA.e.70"}}
>Exit code: 0    Time: 94.61

 

Posted
  On 5/26/2025 at 7:24 PM, TheOne23 said:

why sometimes the code or script I am running exits after _WD_FindElement successfully receives a correct element ID.

Expand  

Because the rest of the code which you didn't present here works exactly like that.

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)

HI @TheOne23,

it would be helpful when you share more code, the website or at least what you try to achieve? At the moment we just have to guess - using iframes!?
What should be done after the iframe content is loaded?

  Reveal hidden contents

By the way: it would be more robust, when you try to use relative XPath expressions instead of absolute XPath expressions. Each time a element is changed at the DOM you have to adjust your absolute XPath. When you use a relative one, this could often be avoided.

Best regards
Sven

Edited by SOLVE-SMART

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

  Reveal hidden contents

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
  • Recently Browsing   0 members

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