Jump to content
Seminko

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

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

Share this post


Link to post
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

Share this post


Link to post
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

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
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"

Share this post


Link to post
Share on other sites

@Seminko

You could try to get the collection of all input tags and check their names :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
Just now, FrancescoDiMuro said:

@Seminko

You could try to get the collection of all input tags and check their names :)

Done that. The element is not there.

This is what my question is about.

Can the element be "protected" in some way?

Share this post


Link to post
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

Share this post


Link to post
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

  • Similar Content

    • By moimon
      Hi all. 
      Sorry if my words are confusing because I am not good at English.
      I am writing code to embed website with Recaptcha in GUI. And then, the code will automatically press the "I'm not a robot" button. The problem here is:
         - The code still works fine when entering iFrame to interact with Recaptcha with the URL is "https://www.google.com/recaptcha/api2/demo"
      <snip>
       
         - But for other URLs (such as "https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php"), the code cannot be entered into the iframe.
       
      Code:
      <snip>  
      I did a lot of research but didn't know why.
       I sincerely thanks for the help. 
    • By SkysLastChance
      I am pretty sure the site that I am using was updated and now I am not seeing the same tags/elements that I used to. I tried using a UIAspy to see if I could grab them that way with no luck. 
      What do I need to do to be able to automate this again. Are the elements hidden somewhere?
      Instead of highlighting established account is highlights all of the web page almost. How can I get to the detail again? 
      I used to grab establish account by the name. Now I have nothing to even try to grab. 
      There are not elements in the event viewer either. 
       


       
      This is what happens when I try to inspect the element and click established account. 
      I get the same type of results in chrome
    • By yffulf
      Is there probably a way to click ie popup button and hide or invisible popup button in the same time?
      I try to use WinSetState @SW_hide ,
      the result is ie crashing or no response because button hide and the next click command won't work...
      $oForm=_IEFormGetObjByName($oIE,"form1") $obutton=_IEFormElementGetObjByName($oForm,"btn_OK") $hWnd = _IEPropertyGet($oIE, "hwnd") _IEAction($obutton,"focus") ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") WinWait("", "確定存檔嗎?") WinSetState("","確定存檔嗎?",@SW_Hide) ControlClick("", "確定存檔嗎?", "[CLASS:Button; TEXT:確定; Instance:1;]")  
    • By _leo_
      Hey there!
      I am having a problem with clicking a button in IE. As you can see in the code, there would be a class name to click it, but since this button exists several times with exactly the same code, I can only use the "Noch nicht veröffentlicht" to separate it from the others. But this part is just pure text without any classification. 
      "<div class="checkmark" data-v-1e5b1f70=""><svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 16 16" data-v-1e5b1f70=""><circle cx="8" cy="8" r="8" data-v-1e5b1f70="" /></svg></div>Noch nicht veröffentlicht"
      I was trying to click it with:
      #include <IE.au3> local $oNNVs = _IEFormGetCollection($oIE2) For $oNNV in $oNNVs If String($oNNV.innertext) = "Noch nicht veröffentlicht" Then _IEAction($oNNV, "click") EndIf Next and:
      $inputs = $oIE2.document.getElementsByTagName("div") For $input In $inputs If $input.innertext == "Noch nicht veröffentlicht" then $input.click() EndIf Next But nothing seems to work. Thanks for the help!
    • By TXTechie
      Hello Everyone,
      I'm looking for a way to use an already open Internet Explorer (IE) window (if one is up and running) and then navigate to a new URL in a new IE tab.
      I thought that _IECreate would easily meet my needs. However, when I use the following script:
      #include <IE.au3> Local $oIE = _IECreate("https://" & $Server & ":8444/", 1, 1, 0, 1) ...with one or more open IE windows, it still opens yet a new IE window.
      Are there any other ideas for how to reliably use an already open IE windows and then how to open a new tab in IE to navigate to a new URL?
      Regards,
      TX Techie
×
×
  • Create New...