1

I'm simply trying to figure out how to automatically click the login button. Nothing I've tried works.

https://www.24option.com/24option/#Trade

I've tried:

$(".loginButton").click()
$("#loginButton").click()
$(".gwt-PushButton.loginButton.gwt-PushButton-up").click()

I've also tried using a few "click simulators" via javascript. Those didn't work either.

Any ideas how to just get the button to click via JS?

4
  • 3
    Use: $('.login_btn').click();. Commented Aug 25, 2013 at 15:32
  • That's what I meant. Sorry. It doesn't work. Commented Aug 25, 2013 at 16:34
  • Basically you want it to auto-click once the form has been filled? Commented Aug 25, 2013 at 17:07
  • Yes. I can fill the form in and I can also "submit" the form but I need to actually click the button not submit the form. The reason for this is because once logged in, the button becomes a logout button and there is no longer a form. Solving for clicking the LOGIN button also solves for clicking the LOGOUT button. Commented Aug 25, 2013 at 17:09

5 Answers 5

1

Have you tried this?

$('.loginButton').on('click', function () {
    //code here
});
Sign up to request clarification or add additional context in comments.

1 Comment

It's not my site. I'm trying to automate using the site.
1
$("#TopPanel").find("#loginForm").submit();

but if you need only the click

$("#TopPanel").find("#loginForm").find('button').click();

After the las edit I think I'll give up, but if you want to keep trying I add this (in case real clicks are being detected somehow, play around with the coordinates or something)

var evt = document.createEvent("MouseEvents");
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
document.getElementById("loginButton").parentNode.dispatchEvent(evt); 

Good luck

6 Comments

Thanks, however, I'm trying to click the button, not submit the form. Once logged in, the button turns to a logout button and is no longer a form and I need to be able to click the logout button as well. So I'm trying to figure out how to trigger the click on the LOGIN button. There has to be a way...
Check the edit and let me know if it works once inside the site
Nope, and when trying it on the main page I get: TypeError: Cannot call method 'find' of null
Well, the click works outside the site (tested on chrome console), I can't test it as a logged user, but it may be the same thing, find the button locating a parent who has an id and then click it
Ah, sorry. 24option.com/24option/#Trade - try that. Nothing will click that login button.
|
0

use

$('.login_btn').click();

or

$('.login_btn').trigger('click');

3 Comments

But the OP didn't ask for performance. They do same thing in this context, I guess: if click() doesn't work, trigger("click") does not work, too.
@JanusP on 24option.com/24option/#Login use $('.grayButton').click();
@TusharGupta - that isn't the same page I need. I need the LOGIN button up top (as the internal logout button works the same). $('.login_btn').trigger('click') does nothing, same with click().
0

Can you show more code? It works fine here:

var btn = document.getElementById("button");
btn.addEventListener("click", function(){ alert("button clicked"); });
btn.click();

Maybe you're having an error with DOM Selection. If you are, try using FireBug or the developer console in Chrome to catch it.

1 Comment

All the code is on the site listed. If you use chrome console or firebug you can see nothing works to click the button.
0

define the click function

$("#loginButton").click(function(){


  alert("clicked");

});

trigger the click function , inside document.ready function

$('#loginButton').trigger('click');

then the button wil be clicked automatically.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.