Jump to content
Sign in to follow this  
Pagi

How to click this menu button? - (Moved)

Recommended Posts

 

<a href="index.php=4143b27b41db0a40c499202865c3e24d" class="menuitem " target="\_self"> "Menu Item 1" </a>

Can you tell me if it´s possible to click this menu button? If yes, how? Cause I have no idea, I think i should use _IETagNameGetCollection

Share this post


Link to post
Share on other sites

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
12 minutes ago, Pagi said:
$currenturl = _IEPropertyGet($oIE,"locationurl")
$oDivs = _IETagNameGetCollection($currenturl, "div")

 

Not sure why you are doing this, as you can't pass the URL as the first parameter of _IETagNameGetCollection. Try this instead --

$oDivs = _IETagNameGetCollection($oIE, "div")

However, I was suggesting to use _IELinkClickByText, like this --

_IELinkClickByText($oIE, "Menu Item 1")

This may not work given the fact that it is part of a menu.

Share this post


Link to post
Share on other sites
$oClasses = _IETagNameGetCollection($oIE, "class")
For $oClass in $oClasses
   If StringInStr($oClass.innertext, "Menu Item 1") Then
      _IEAction($oClass, "click")
   EndIf
Next

 

I tried to identify it by the class but it still doesn´t work. Any other idea? Or is there any mistake?

Danp, thanks for your reply, _IELinkClickByText does´nt work and also I don´t want to solve it like that. I just need to identify some element and then click on the menu button.

 

Share this post


Link to post
Share on other sites

But there is no div in HTML code..  Only tag <a> and class but problem with class is, that the same class has got more elements

Share this post


Link to post
Share on other sites

Ok... but you had previously shown code where you were searching by div, so this led me to believe that the link was contained within a div.

You've only shown us a single element, so it's not possible to guess the context that it resides in. Suggest that you shown us more of the surrounding HTML code. Also, it would be good to know if there are any events attached to these elements. If so, which ones?

Share this post


Link to post
Share on other sites

Have you tried accessing the div element and then the contained links? Something like this --

$oDiv = _IEGetObjById($oIE, "submenu2")
$oLinks = _IETagNameGetCollection($oDiv, "a")

For $oLink In $oLinks
   If StringInStr($oLink.innerText,"Menu Item 1") Then
      _IEAction($oLink, "click")
      ExitLoop
   EndIf
Next

 

Share this post


Link to post
Share on other sites

It´s working! But only on Main Button. I think the reason are apostrophes. I tried to include them in code but nothing...

Share this post


Link to post
Share on other sites

It´s not working on other buttons, only on button called "Main Button".  Look at the screenshot up and u will understand.

Share this post


Link to post
Share on other sites

You should show your code because the code I posted was intended to target "Menu Item 1". If you've changed the code so that it now works for "Main Button", then it helps if you include these details in your responses.

Also, since you posted a screenshot instead of the actual HTML code, it isn't possible for me to take a closer look at the HTML.

Share this post


Link to post
Share on other sites

Page is not uploaded yet so <a> href links will not work. Here is the offline file of the HTML. That´s just random links I put in

Pagi_blog.html

Edited by Pagi

Share this post


Link to post
Share on other sites
$oDiv = _IEGetObjById($oIE, "submenu2")
$oLinks = _IETagNameGetCollection($oDiv, "a")

For $oLink In $oLinks
   If StringInStr($oLink.innerText,"Menu Item 1") Then
      _IEAction($oLink, "click")
   EndIf
   ExitLoop
   Next
EndFunc

Doesn´t work. If I write in code "Main Button" to target Main Button like this,

$oDiv = _IEGetObjById($oIE, "submenu2")
$oLinks = _IETagNameGetCollection($oDiv, "a")

For $oLink In $oLinks
   If StringInStr($oLink.innerText,"Main Button") Then
      _IEAction($oLink, "click")
   EndIf
   ExitLoop
   Next
EndFunc

 

it works. But for menu items 1,2,3,4,5 not.

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By MiKa666
      Hi all,
      I'm developing a tool for exploratively testing another software. For that I wanna cover all the GUI functionality from that software and verify everything works as intended. But now I've a problem which I couldnt solve so far.
      One thing that software I'm testing does, is to load up either a single picture or a series of pictures. Depending on how much pictures got loaded, further actions will be proceeded...
      This loaded pictures are schon within a ToolbarWindow and they're clickable. What I need to know is, how much pictures are in this ToolbarWindow...
      Can anybody provide me a tip on how to achive this?
      Would be amazing!!
      BR,
      Mic
    • By meety
      Hello!
      wingettext function can get the text content of the IE browser page, but the text content of the page cannot be obtained in the chrome browser? What should I do?
    • By DirtyJohny
      Hi everyone.Need rewrite this function how in еxample.
      Original:
      #RequireAdmin #NoTrayIcon Opt("MustDeclareVars",1) Func _a() Local $sls=ObjGet("winmgmts:{impersonationLevel=impersonate," _ &"authenticationLevel=Pkt}!\\"& _ @ComputerName&'\root\wmi'),$lss=$sls.ExecQuery _ ('SELECT * FROM WmiMonitorID'), _ $lll,$sll,$sss="",$lsl,$lls,$i,$z For $z In $lss $lsl=$z.UserFriendlyName For $i=0 To Ubound($lsl)-1 if ($lsl[$i]) Then $lll&=Chr($lsl[$i]) Next $lls=$z.SerialNumberID For $i=0 To Ubound($lls)-1 if ($lls[$i]) Then $sll&=Chr($lls[$i]) Next $sss&="Model"&@TAB&@TAB&": "&$lll&@CR&"Serial Number"&@TAB&": "&$sll&@CR&@CR $lll="" $sll="" Next MsgBox(262144,'Monitors '&$lss.Count,$sss&" "&@CR) $lss=Null $sls=Null EndFunc _a() Example:
      Func _InfoPC() Local $ObjService = ObjGet('winmgmts:{impersonationLevel = impersonate}!\\' & @ComputerName & '\root\cimv2') Local $ObjMB = $ObjService.ExecQuery('SELECT * FROM Win32_BaseBoard', 'WQL', 0x30) If IsObj($ObjService) Then For $objItemMB In $ObjMB $sInfo &= @TAB & 'Motherboard: ...... ' & $objItemMB.Product & @CRLF I'm beginner in this sphere and need  you all speak easy and simply because i'm Russian.Thanks)
    • By Deshanur
      Am trying to automate injecting credential on the login form for all kind of Web application for IE. I know how to identify the form name by viewing the source code and using the method - _IEFormGetObjByName($ie, $form_Name).
      I would like to know how to identify or get the form object for the web app where there is no form name tag for example below, for the is I have used - _IEFormGetCollection($ie, 0) to get the form object.
      My Question is does it work for all kind of application "_IEFormGetCollection($ie, 0)" how to identify Index value? is it always 0? is there any better solution?
      The final solution am looking for is find out form object, get the username, password field and inject credential and submit the form.
      How to find out index value? for the forms which does not have form name field.
      $login_form = _IEFormGetCollection($ie, 0) $email_field = _IEFormElementGetObjByName($login_form, $form_UserName) $pass_field = _IEFormElementGetObjByName($login_form, $form_password) $login_button = _IEFormElementGetObjByName($login_form, $form_submitbutton) _IEFormElementSetValue($email_field, $CmdLine[2]) _IEFormElementSetValue($pass_field, $CmdLine[3]) ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]","{Enter}") OR This works fine if the form has form name. $login_form = _IEFormGetObjByName($ie, $form_Name) $email_field = _IEFormElementGetObjByName($login_form, $form_UserName) $pass_field = _IEFormElementGetObjByName($login_form, $form_password) $login_button = _IEFormElementGetObjByName($login_form, $form_submitbutton) _IEFormElementSetValue($email_field, $CmdLine[2]) _IEFormElementSetValue($pass_field, $CmdLine[3]) ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]","{Enter}")
    • By JuanFelipe
      Hello guys!
      I have a problem with a script, in the past I made a program and it worked perfect, I recently used it again and it already stands still in one step, the problem is a Javascript event that changed but now I cannot execute it.
       
      <td colspan="2" align="center"><input type="button" id="Buscar" name="Buscar" value="Buscar" onclick="javascript:enviarForma(document.obtenercasosPersonaPorDocumento,'0');" class="boton"></td>  
      Previously I used this code and it worked, but now it does nothing
      $botonconsulta = _IEGetObjByName($oIE,"Buscar") _IEAction($botonconsulta, 'click') _IELoadWait($oIE)  
      Now I have tried the following codes but none works.
       
      ;==================== 1 _IEHeadInsertEventScript($oIE, "document", "onclick", "javascript:enviarForma(document.obtenercasosPersonaPorDocumento,'0');") ControlClick("SUPER CELAC", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]") _IELoadWait($oIE) ;==================== 2 $forma = $oIE.document.obtenercasosPersonaPorDocumento $oIE.Navigate("JavaScript:enviarForma("&$forma&",""0"");") _IELoadWait($oIE) ;==================== 3 $boton = _IEGetObjById($oIE, "Buscar") $boton.document.parentwindow.execScript("enviarForma(document.obtenercasosPersonaPorDocumento,'0');", "javascript") I hope you can guide me, because I think the error is in the parameters that the javascript function receives but I don't know how to send it, here I leave the first part of the JavaScript function.
      function enviarForma(frm,tipoForma){ var bExisteDatoConsulta = false; var bError=true; var mensajeError=""; switch (tipoForma) { //--Forma documento case "0": if (validar_campo_no_vacio_no_print(frm.numeroDocumento)) { if (!isNum(frm.numeroDocumento.value)) { bError = false; mensajeError += "El número de documento debe ser un valor numérico\n"; } bExisteDatoConsulta = true; } else { mensajeError += "Debe digitar un número de documento\n"; } break;  Thanks!
×
×
  • Create New...