0

I am not able to click the button directly. I want to automate a condition like this in jQuery. The condition is, if I am not able to click the button manually - for example if it is behind something, don't click the button in automation.

$(document).ready(function () {
    setTimeout(function () {
        $("input").click()
    }, 1000)
})
div {
    position:fixed;
    height:100px;
    width:100px;
    background:transparent;
    z-index:10;
    border:solid 1px;
    top:0px;
    left:0px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input type="button" onclick="alert()">
<div></div>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
Venkat
  • 603
  • 1
  • 8
  • 17
  • http://jsfiddle.net/ooro8Lqc/ click this link to what i have done – Venkat Apr 02 '15 at 06:51
  • @Jocker http://jsfiddle.net/ooro8Lqc/ – Venkat Apr 02 '15 at 06:52
  • I put your code into the question. Now please elaborate on what you mean with the condition. Do you mean `if ($("input").is(":visible")) $("input").click();` – mplungjan Apr 02 '15 at 06:57
  • The button is hide behind the div, manually i am not able to click the button, but the code i written in the script, clicks the button. My question is :- If i am not able to click the button manually, the script also don't click the button. – Venkat Apr 02 '15 at 07:01
  • @VenkatGan what you want to achieve, using such structure? – demonofthemist Apr 02 '15 at 07:04
  • @rohanAM I want to find a button is hidden behind the div or not. – Venkat Apr 02 '15 at 07:06
  • Try this - only thing I could find. :visible does not work. http://stackoverflow.com/questions/9914457/determine-visibility-real-z-index-of-html-elements – mplungjan Apr 02 '15 at 07:21

0 Answers0