Jump to content

How to click on a javascript link/button?


Recommended Posts

Hello guys, I need to click on a javascript link, at least that's what I think it is. Here is the screenshot to help you guys understand

Posted Image

I tried geting it's X and Y position on the screen manualy but that does not work for all cases, because the position of the button changes depending on the page contend. The "button" I want to click is the "Veja telefone e fax" in the picture.

Thanks in advance! :x

EDIT for more info: What I click on this button a small window appears in the middle of the SAME page showing the info I need to access(I couldn't find this info on the HTML code)

Also, I can't select this button by tabbing

Edited by pedmacedo
Link to comment
Share on other sites

Already tried with _IEFormGetCollection and _IEFormElementGetCollection combined togherer with an _IeAction click at the end?

And with Controlsend?

You might also want to try WinHttp.au3 after catching the POST or GET header that the button sends.

Nothing else comes up in my mind for now

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Link to comment
Share on other sites

Thanks for the sugestions Newb. I just found out that I can use _IENavigate($ie,"javascript:showTelPerfil(1);")

JohnOne looks like that's not what happened, I rapidly received 2 replies.

Anyway, sorry for doing that.

Edited by pedmacedo
Link to comment
Share on other sites

Thanks for the sugestions Newb. I just found out that I can use _IENavigate($ie,"javascript:showTelPerfil(1);")

JohnOne looks like that's not what happened, I rapidly received 2 replies.

Anyway, sorry for doing that.

You got lucky :x

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Hey folks, I solved this problem but another one arised, when I use

_IENavigate($ie,"javascript:showTelPerfil(1);")

The script doesn't do anything else, it just sits idle(not paused). So then I thought using _IENavigate without waiting for the page to load

_IENavigate($ie,"javascript:showTelPerfil(1);",0)

And now the following error occurs:

Posted Image

Any idea about what could be causing the problem? Are we supposed to use _IENavigate with javascript code?

Again, thanks for any help!

Edit: If I manually navigate to any other site(while the script is running) it starts working again, till it reaches this line of code again (it's a loop)

Edited by pedmacedo
Link to comment
Share on other sites

There must be something else going on. Whether you tell it to wait or not, the URL will get processed in $o_object.navigate. When you tell it not to wait, it simply returns to your code without entering the wait loop for page completion... is there another _IENavigate after this that may be triggering the error?

Did you try _IELinkClickByText($oIE, "Veja telefone e fax") ???

Suggest you get DebugBar (see my sig) to examine the HTML... you need to understand that View Source shows you the HTML before any client processing, DebugBar will shouw you the final markup.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

The remark you are referring to is trying to tell you that other elements, like DIV, can look like links and are not... _IELinkClickByText has no restriction with anything to do with Javascript.

Remarks

Not all elements that appear to be links actually are. It is common practice to attach onclick Javascript events to other DOM elements to simulate the behavior of links. To activate such elements, use "click" with _IEAction.

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

  • 6 years later...

In many cases _IEAction "click" does not work with javascript-related buttons. I found a way to create a mouseevent and send it to the button to trigger the javascript linked here, which might work when IE's .click() does not.

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

This thread is 6 years old, no one cares anymore.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...