Jump to content
Nareshm

Check If Object exist in IE

Recommended Posts

Nareshm

How can i check the id is exists in IE?

i want to check if id = mydocument exists in already opened webpage in IE then msg box("id found"), if the id = mydocument not exists then msgbox(id not found)

Share this post


Link to post
Share on other sites
Danp2

Please clarify your goal because I'm unclear what you are trying to do. Do you want to check for the existence of a specific element? Or something else?

What have you tried thus far?

Share this post


Link to post
Share on other sites
Juvigy

Check out _IEGetObjbyID

Share this post


Link to post
Share on other sites
FabioPinheiro

I understand.

I have:

      Sleep(30000)
      $oLink = _IEGetObjById($oIE, 'ctl00_FooterContent_confirmacaoUsuario_BtnSim_LinkButton1')
      _IEAction($oLink, 'click')

Sometimes Sleep(30000) is not suficient time to wait.

How I WAINTING a _IEGetObjById EXISTS in the display to click?

Example:

$oLink = _IEGetObjById($oIE, 'ctl00_FooterContent_confirmacaoUsuario_BtnSim_LinkButton1')
if($oLink) exists Then
      _IEAction($oLink, 'click')
Else
  Sleep(5000)
End if

OR

$oLink = _IEGetObjById($oIE, 'ctl00_FooterContent_confirmacaoUsuario_BtnSim_LinkButton1')
While not isObj($olink)
     Sleep(5000)
WEnd

HOW I WAIT THE OBJ EXISTS TO CLICK?

THANKS!!!!!

Share this post


Link to post
Share on other sites
FabioPinheiro

I have:

      Sleep(30000)
      $oLink = _IEGetObjById($oIE, 'ctl00_FooterContent_confirmacaoUsuario_BtnSim_LinkButton1')
      _IEAction($oLink, 'click')

Sometimes Sleep(30000) is not suficient time to wait.

How I WAINTING a _IEGetObjById EXISTS in the display to click?

Example:

$oLink = _IEGetObjById($oIE, 'ctl00_FooterContent_confirmacaoUsuario_BtnSim_LinkButton1')
if($oLink) exists Then
      _IEAction($oLink, 'click')
Else
  Sleep(5000)
End if

OR

$oLink = _IEGetObjById($oIE, 'ctl00_FooterContent_confirmacaoUsuario_BtnSim_LinkButton1')
While not isObj($olink)
     Sleep(5000)
WEnd

HOW I WAIT THE OBJ EXISTS TO CLICK?

THANKS!!!!!

Share this post


Link to post
Share on other sites
FabioPinheiro

Danp2. Thanks, but not working.

--- begin ---

      _IEErrorHandlerRegister()
      Do
         Sleep(500)
         $oLink = _IEGetObjById($oIE, 'ctl00_FooterContent_confirmacaoUsuario_BtnSim_LinkButton1')
      Until IsObj($oLink)
      _IEAction($oLink, 'click')

--- end ---

 

Whats wrong?

 

Share this post


Link to post
Share on other sites
FabioPinheiro
2 minutes ago, FabioPinheiro said:

Danp2. Thanks, but not working.

--- begin ---

      _IEErrorHandlerRegister()
      Do
         Sleep(500)
         $oLink = _IEGetObjById($oIE, 'ctl00_FooterContent_confirmacaoUsuario_BtnSim_LinkButton1')
      Until IsObj($oLink)
      _IEAction($oLink, 'click')

--- end ---

ERROR:

--> IE.au3 T3.0-2 Warning from function _IEGetObjById, $_IESTATUS_NoMatch (ctl00_FooterContent_confirmacaoUsuario_BtnSim_LinkButton1)

Whats wrong?

 

 

Share this post


Link to post
Share on other sites
Danp2
10 hours ago, FabioPinheiro said:

Whats wrong?

No idea because you didn't post a runnable script and you didn't provide any additional details such as the contents of the Scite output window.

What version of AutoIT are you using? FWIW, you should see that error repeatedly until the object is found. If the object is never found, then it doesn't exist. :blink:

Share this post


Link to post
Share on other sites
Juvigy

So this line:

$oLink = _IEGetObjById($oIE, 'ctl00_FooterContent_confirmacaoUsuario_BtnSim_LinkButton1')

oLink will not be an object if the ID is missing. So after the call check with "IsObj" and if not object - wait.

Share this post


Link to post
Share on other sites
FabioPinheiro

Hi, Juvigy.

ctl00_FooterContent_confirmacaoUsuario_BtnSim_LinkButton1 is a HTML ID. Look:

<a href="#" id="'ctl00_FooterContent_confirmacaoUsuario_BtnSim_LinkButton1" onclick="confUser()">Confirmar Usuário</a>

This link open in a modal popup, after ready a json. When i click i first link, open a modal, but before have a loading. This loading has a delay that depends on the system. it can take 1, 2, 3 ... N minutes. The Sleep command is very useful, but I set 5 minutes, when it takes 2 and I lose time.

 

I need a command that will wait until an HTML ID exists on the page. It cant be WinWait because it is an AJAX.

Thanx!

Share this post


Link to post
Share on other sites
Juvigy

So you should detect when the modal popup appears. Depending on what kind is that popup you can use WinWaitActive or IE functions.

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

×