Jump to content

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

Link to comment
Share on other sites

  • Moderators

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!

Link to comment
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.

Link to comment
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.

 

Link to comment
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?

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

 

Link to comment
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.

Link to comment
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.

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...