Home > OS >  javascript click web div
javascript click web div

Time:06-12

some need help with automatic clicking in javascript or jquery

I would like you to automatically click on

<button >LOGUJ</button>

wait 5 seconds then click

<input type="submit" value="LOGUJ"  style="top: 5px;cursor:pointer">

wait 5 seconds then click

<div ></div>

wait 5 seconds then click

<div  id="tutorial_item_16">
        <div ></div>
    </div>

wait 5 seconds checked if everything is correct

<div >79/79</div>

if so click

<div  data-nerve="70" data-percent="95" data-need="70n">
                                <div >$18 000</div>
                            </div>

then to wait 30 seconds and start all over again my code

setTimeout(function() {
var xPathRes2 = document.evaluate ('//*[@id="welcome_container"]/div[3]/div/form/div[2]/button', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
xPathRes2.singleNodeValue.click();
    }, 3500);



setTimeout(function() {
const inputElement = document.querySelector('input[value="LOGUJ"]');

inputElement.addEventListener('click', () => {

    // log "Hello" in the console when clicked
    console.log("hello");

})

// simulate a click on the input element with the click() method
inputElement.click();
    }, 5500);
setTimeout(function() {
var list = document.getElementsByClassName("closeCover new popup");
for (var i=0; i<list.length; i  ) list[i].click();
    }, 6500);

setTimeout(function() {
var list = document.getElementsByClassName("wars");
for (var i=0; i<list.length; i  ) list[i].click();
    }, 7500);

setTimeout(function() {
   document.getElementById('tutorial_item_16').click();
    }, 9000);

setTimeout(function() {
var xPathRes2 = document.evaluate ('//*[@id="content_main"]/div[1]/div[2]/div[1]/div[4]/div/div[1]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
xPathRes2.singleNodeValue.click();
    }, 11000);

setTimeout(function() {
   document.getElementById('tutorial_item_14').click();
}, 12500);

setTimeout(function() {
var xPathRes1 = document.evaluate ('//*[@id="trainAll"]/div[2]/div/span', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
xPathRes1.singleNodeValue.click();
}, 13800);

setTimeout(function() {
var list = document.getElementsByClassName("myLink logout icon");
for (var i=0; i<list.length; i  ) list[i].click();

    }, 15000);

CodePudding user response:

You can use setTimeOut function like this.

setTimeout(function() {
    $('._my_save_button').trigger('click');
}, 3000);

Hope this helps!

CodePudding user response:

Hi i think you need the setInterval() function in javascript. i provide sample code for the use of this function.

HTML

<button id="mybtn" onclick="saySomething()">click me</button>

JAVASCRIPT

let btn = document.getElementById("mybtn");


function saySomething(){
    alert("hello");
}

function clickFunc(){
    btn.click();
}

setInterval(clickFunc, 3000);
  • Related