Jump to content

[SOLVED] IE - element with an existing ID can't be found


Seminko
 Share

Recommended Posts

Strange thing. When I load a page in IE and inspect, the elements are clearly there but when I try to find them using _IEGetObjById or _IETagNameGetCollection or even using JS right in the IE console, the elements can't be found.

Have you guys even encoutered something similar?

Site's HTML

<div id="lastdays">
  <div class="radio">
    <span class="radio"><input id="lastdays_radio" type="radio" name="rangepanel_group" value="lastdays_radio"></span>
  </div>
  <div class="content">
    <label for="lastdays_radio">Za posledních</label>
    <label for="lastdays_radio"> </label>
    <input name="lastdays_days" type="text" value="1" maxlength="3" id="lastdays_days" class="text days" onclick="document.getElementById('lastdays_radio').checked=true;" onfocus="document.getElementById('lastdays_radio').checked=true;">
    <label for="lastdays_radio"> </label>
    <select name="lastdays_period" id="lastdays_period" class="combo" onclick="document.getElementById('lastdays_radio').checked=true;" onfocus="document.getElementById('lastdays_radio').checked=true;">
      <option value="D">dnů</option>
      <option value="W">týdnů</option>
      <option selected="selected" value="M">měsíců</option>
    </select>
  </div>
</div>
document.getElementById("lastdays_days"); //returns null in IE

 

Edited by Seminko
Link to comment
Share on other sites

It has nothing to do with my code. At least I don't see a reason why it would since the element cannot be found using IE's own console (but it is there in the explorer, both in IE and Chrome).

This is more of a general question.

Anyways, here's the code, just to be sure I'm not missing something:

Local $oIE = _IECreate($URL)

_IELoadWait($oIE)
Sleep(5000)
    
$ClickLastDays = _IEGetObjById($oIE, "lastdays_days")
If $ClickLastDays = 0 Then
    MsgBox(16, "Error", "Click error - lastdays_days")
    Exit
Else
    _IEAction($ClickLastDays, "click")
    If @error Then
        MsgBox(16, "Error", "Can't click $ClickLastDays")
        Exit
    EndIf
EndIf

Btw, when I'm logging into the page everything works fine, with other elements.

 

EDIT: based on my code, I get the first error: 'Click error - lastdays_days' - in other words, the element cannot be found

Edited by Seminko
grammar
Link to comment
Share on other sites

@Seminko

Because you shouldn't check the error in that way...

The function reference doesn't say that in case of failure, the function returns 0, but just that it sets the @error code to non-zero, so, try to remove that "bad" check and see if it works (as you are doing for _IEAction()) :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

4 minutes ago, FrancescoDiMuro said:

@Seminko

Because you shouldn't check the error in that way...

The function reference doesn't say that in case of failure, the function returns 0, but just that it sets the @error code to non-zero, so, try to remove that "bad" check and see if it works (as you are doing for _IEAction()) :)

Agreed, It works for all the other elements, though.

Anyways, just as I said in my initial post. The element cannot be found: "7 ($_IEStatus_NoMatch) - No Match"

Link to comment
Share on other sites

18 hours ago, Danp2 said:

Have you checked to see the the site uses frames?

You were right. In IE the site creates a frame.

<iframe height="894" class="ombframe" id="ombframe" src="/csite/frames.aspx?module=account_oper_list" style="width: 100%; padding-top: 25px; min-height: 600px;" sandbox="allow-modals allow-top-navigation allow-popups allow-forms allow-scripts allow-same-origin"></iframe>

TIL

 

Solved, thanks @Danp2

Edited by Seminko
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...