如何使用噩梦点击此链接? [英] How do I click this link using nightmare?

查看:123
本文介绍了如何使用噩梦点击此链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是涉及链接的所有内容:

Here is everything involving the link:

<a class="" data-images="{&quot;detail_url&quot;:&quot;//assets.supremenewyork.com/148393/ma/hBwFmRXhVKI.jpg&quot;,&quot;zoomed_url&quot;:&quot;//assets.supremenewyork.com/148393/zo/hBwFmRXhVKI.jpg&quot;}" data-style-name="Black" data-style-id="19033" data-sold-out="false" data-description="null" href="/shop/bags/lkav6jh17/xfdbgpiea" data-no-tubolink="data-no-tubolink"><img width="32" height="32" src="//d17ol771963kd3.cloudfront.net/148393/sw/hBwFmRXhVKI.jpg" alt="Hbwfmrxhvki"></a>

我使用带有原子编码节点的噩梦,并想点击网址上的黑色书包: http://www.supremenewyork.com/shop/bags/lkav6jh17/p9ylgt8vm

使用元素中的data-style-name =Black。

I use nightmare with node coded in atom and would like to click on the black bookbag from the url: http://www.supremenewyork.com/shop/bags/lkav6jh17/p9ylgt8vm
using the "data-style-name="Black" found in the elements.

我试过:

.click("data-style-name ='Black'")

给了我错误:

Failed to execute 'querySelector' on 'Document': 'data-style-name ='Black'' is not a valid selector.

不知道该怎么做才能点击,但任何帮助都会很棒。链接是图片,也是网页上列表元素的一部分。

Not sure what to do to click but any help would be great. The link is an image and part of a list element on the webpage.

推荐答案

首先获取DOM节点并分配给变量然后单击节点。还需要在选择器周围添加括号和d除非值中有空格或其他无效字符,否则不需要内部单引号

first grab the DOM node and assign to a variable then click on the node. Also you need to add brackets around the selector and don't need the inner single quotes unless there is a space or other invalid character in the value

var myLink = document.querySelector("[data-style-name=black]");
.click(myLink)

这篇关于如何使用噩梦点击此链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆