TypeError:无法读取 null 的属性“单击"

TypeError: Cannot read property #39;click#39; of null(TypeError:无法读取 null 的属性“单击)
本文介绍了TypeError:无法读取 null 的属性“单击"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用这些代码在 Twitter 上大量关注/取消关注/收藏/取消收藏;

I have been mass following / unfollowing / favoriting / unfavoriting on twitter with these codes ;

$('button.follow-button').click();
$('button.ProfileTweet-actionButtonUndo').click();
$('a.favorite').click();

我在网上找到了一些不工作的代码并尝试修复,所以它们现在几乎可以工作了.唯一的事情就是去谷歌浏览器上的页面,按 f12 ,打开控制台并运行命令.

I found some not-working codes online and tried to fix, so they are nearly working now. The only thing is to go to the page on google chrome, press f12 , open console and run the command.

所以现在,我想在 Vine 中使用相同的系统.谷歌浏览器有一个扩展来使用 vine ( https://client.vineclient.com/ ) 和我正在尝试使用它,因为原始网页( vine.co )甚至没有用.

So now, I wanted to use the same system in Vine. There"s an extension for google chrome to use vine ( https://client.vineclient.com/ ) and I am trying to use it because original webpage ( vine.co ) is not even useful.

twitter 和this 的唯一区别是,在 vine 客户端的 ^followers^ 部分中,页面中会出现一个弹出窗口.而且我不知道它是否检测到按钮.

The only difference between twitter and this, is that, in vine client for ^followers^ section, an pop-up comes in the page. And I don!t know if it detects the buttons.

所以,我试图从原始页面点击的按钮的代码,(我使用开发人员工具/元素获取它)

So , the code of the button I am trying to click from original page , ( I took it using developer tools / elements )

<div class="user">
<img alt="Tuğçe Nur TEKİN" class="avatar" src="http://v.cdn.vine.co/r/avatars/3C2E4F40F11066473630650847232_pic-r-1397241239141e51579937f.jpg.jpg?versionId=ttIz4CExCjW_4TEnxYbnehPPpXRyzMco">
<div class="wrapper">
<a class="username" 
href="https://client.vineclient.com/explore/users/1066473613911363584">
Tuğçe Nur TEKİN
</a>
</div>
<a class="button follow" data-id="1066473613911363584">
<i class="icon">
</i>
</a>
</div>

要点击的东西在这里:

当我手动点击时,它会变成这样:

When I manually click, it changes into this :

<a class="button unfollow" data-id="1066473613911363584"><i class="icon"></i></a>

以及我用来尝试点击的命令

And the command I use to try to click

$(".a.follow").click();

我得到的错误,

TypeError: Cannot read property 'click' of null

我该如何解决这个问题?顺便说一句,在这些代码中,我实际上找不到任何 ^button^ 代码..谢谢!

How can I fix that? By the way, in these codes, I couldn"t find actually any ^button^ codes.. Thanks!

更新

  1. http://prntscr.com/3pmo2i
  2. http://prntscr.com/3pmoyk
  3. http://prntscr.com/3pmpym

推荐答案

我遇到了这个问题,当我从其他地方(例如 Selenium)在网页上运行 javascript 同时使用开发者工具时.尝试关闭开发者工具并运行脚本.

I had encountered this problem, when I run javascript on the webpage from elsewhere (eg. Selenium) while simultaneously using Developer Tools. Try closing Developer Tools and run the script.

这篇关于TypeError:无法读取 null 的属性“单击"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Update another component when Formik form changes(当Formik表单更改时更新另一个组件)
Formik validation isSubmitting / isValidating not getting set to true(Formik验证正在提交/isValiating未设置为True)
React Validation Max Range Using Formik(使用Formik的Reaction验证最大范围)
Validation using Yup to check string or number length(使用YUP检查字符串或数字长度的验证)
Updating initialValues prop on Formik Form does not update input value(更新Formik表单上的初始值属性不会更新输入值)
password validation with yup and formik(使用YUP和Formick进行密码验证)