Need list of links and child page paths from a website using Nightwatch

时间:2017-04-06 17:15:19

标签: nightwatch.js

Is it possible to get list of URL's / links available in a website by providing base URL as an input. Using nightwatch, if i pass base URL it should give all hyperlinks, child pages links etc. using Nightwatch. If its possible, how we can achieve it.

1 个答案:

答案 0 :(得分:0)

不确定Nightwatch是您正在尝试实现的目标的正确选择。也许您可以通过页面提取的网址列表告诉我们您想要做什么? 您可以通过页面对象配置设置URL,当页面加载时(page.navigate()),您可以返回所有链接元素。类似的东西:

browser
  .elements("css selector", "a", result => {
     // Do something with 'result' that will contain all the elements matching "a"
  })

但我建议您阅读更多关于Nightwatch的信息,以确定这是否适合您的需求。

有关守夜人的更多信息:http://nightwatchjs.org/gettingstarted

有关Page对象的更多信息:https://martinfowler.com/bliki/PageObject.html