Cannot read property 'click' of null

5,433 views
Skip to first unread message

kobe...@gmail.com

unread,
Aug 5, 2018, 1:26:01 AM8/5/18
to Autofill Chrome Extension
website: https://www.hpb.gov.tw/p/412-1000-116.php?Lang=zh-tw

I want auto click left button by Autofill.

Type = JavaScript  Value = document.querySelector('input[type="submit"]').click();

But it doesn't work,

debug console show below message:


[Autofill] The following JavaScript code was not executed:
document.querySelector('input[type="submit"]').click()
Error: Cannot read property 'click' of null

thdoan

unread,
Aug 5, 2018, 11:39:08 PM8/5/18
to Autofill Chrome Extension
That's because when it goes to the next page there are two inputs there that match input[type="submit"]. Try changing your JS code to this:

document.querySelector('input[name="ctl00$ContentPlaceHolder1$btnOK"]').click();

samthebe...@gmail.com

unread,
Jul 13, 2019, 11:54:51 PM7/13/19
to Autofill Chrome Extension
i also kind of had the same problem, my code was:
$(document).ready(function clickbutton(){
    'use strict';
setInterval(function($){ document.getElementById('nextactivity').click(); },15000);
})(jQuery);
and it said: caught TypeError: Cannot read property 'click' of null.
hope you can help!
thanks
Reply all
Reply to author
Forward
0 new messages