Jump to content
Caria

How can I click an element in script

Recommended Posts

I have an internal website:

<html>
  <head>...</head>
  <body>
    <div class="" id="wrapper">
      <div class="contIframe noLnb">
        <iframe name="contentIframe" id="contentIframe" src="/wl/com/shared/getPortal.do">
          <html>
            <head>...</head>
            <frameset name="tqmSet" id="tqmSet">
              <frame name="tqmFrame" id="tqmFrame">
                <html>
                  <head>...</head>
                  <body>
                    <form name="LeftMenuProjectForm" id="LeftMenuProjectForm">
                      <div class="bgLightGray paddR0">
                        <div class="blueTreeH" id="menu_1">
                          <span class="arrow">
                            <a onclick="changeTop('default')" href="javascript:void(0)">ABC</a>
                          </span>
                  
.................................

I can getElementById the contentIframe, but cannot getElement into it.

Now I want to click to ABC, please help me!

Share this post


Link to post
Share on other sites

First use _IEFrameGetCollection to get the frame and them _IELinkGetCollection to get the link and click on it with _IEAction

Share this post


Link to post
Share on other sites
1 hour ago, Juvigy said:

First use _IEFrameGetCollection to get the frame and them _IELinkGetCollection to get the link and click on it with _IEAction

Hi Juvigy, thank you for you support!

But when I try it

$obj5 = _IEFrameGetCollection($web)
   $numFrame = @extended
   MsgBox(0,"","Frames found: " &$numFrame)
   For $i=0 To $numFrame-1
      $obj6 = _IEFrameGetCollection($web, $i)
      $obj7 = _IELinkGetCollection($obj6)
      $numLink = @extended
      MsgBox(0,"","Frame " &$i &" found " &$numLink &" links")
      For $j=0 To $numLink-1
         MsgBox(0,"","i=" &$i &", j=" &$j &", link: " &$obj7.href)
      Next
   Next

the result is:

Quote

Frames found: 9
Frame 0 found 0 links
Frame 1 found 0 links
Frame 2 found 0 links
Frame 3 found 0 links
Frame 4 found 0 links
Frame 5 found 0 links
Frame 6 found 0 links
Frame 7 found 0 links
Frame 8 found 0 links

it cannot found any link in frames! :(

Share this post


Link to post
Share on other sites

Maybe you could try something like this :

Local $oFrm1 = _IEFrameGetObjByName ($web,"contentIframe")
Local $oFrm2 = _IEFrameGetObjByName ($oFrm1,"tqmFrame")
Local $colA = _IETagNameGetCollection ($oFrm2,"a")
For $a in $colA
  if $a.innerText = "ABC" then
    $a.click ()
    ExitLoop
  endif
Next

 

Share this post


Link to post
Share on other sites
14 hours ago, Nine said:

Maybe you could try something like this :

Local $oFrm1 = _IEFrameGetObjByName ($web,"contentIframe")
Local $oFrm2 = _IEFrameGetObjByName ($oFrm1,"tqmFrame")
Local $colA = _IETagNameGetCollection ($oFrm2,"a")
For $a in $colA
  if $a.innerText = "ABC" then
    $a.click ()
    ExitLoop
  endif
Next

 

Many thanks to you! It's work! 😂 Thank you very much! ^^

Share this post


Link to post
Share on other sites
13 hours ago, junkew said:

Maybe you have nested frames so more then the 9 of the main page. Whats developer tool showing for the hierarchy

I'm a DOM AutoIT newbie, so many things I've never met before.

Thanks for your support!

Share this post


Link to post
Share on other sites
Posted (edited)

Hi everybody. I have a trouble.

When I click an element, it open a new IE Window named "XYZ".
I can use _IEAttach to attach it into an object by the title, and hide it (with _IEAction invisible).
But the time from I clicked to element to the time new Window loaded title (to hide it) , it's shown a blank window, and I don't like this.

How can I hide it completely and nothing (new blank window not appeared).

Thank you!

Edited by Caria

Share this post


Link to post
Share on other sites

Hi Caria,

When you manually click it - is it behaving the same? One way to do this is to hid the entire IE as an application before clicking and show the first instance only after you have attached to the new window that will remain hidden.

Share this post


Link to post
Share on other sites
16 hours ago, Juvigy said:

Hi Caria,

When you manually click it - is it behaving the same? One way to do this is to hid the entire IE as an application before clicking and show the first instance only after you have attached to the new window that will remain hidden.

Hi Juvigy,

I understand what you mean: Hide all IE window, and click (and bla bla bla), and show back all IE window...
But when user is using IE, it's not really good. :(

Share this post


Link to post
Share on other sites

It depends how you started IE or attached to it, but you can start a separate instance of IE, then hide only that instance and leave whatever the user has intact.

Share this post


Link to post
Share on other sites

Whats the issue with a white window? You could draw a picture in it or make it black.🤔 what kind of solution do you expect as i assume same would happen when a user clicks. You could resize, hide, move window away but for me unclear what your requirement is.

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

×
×
  • Create New...