4

In the nightwatch documentation I can see that there are both the urlContains and urlEquals assertions that can be specified in a nightwatch.js but these do not allow xpath selectors. I have applied the global parameter to use Xpath everywhere (I will explain below) but I am looking for a way to assert (in a fuzzy way) that the URL of the current page matches a pattern.

The reason is that I test on numerous instances of the same application which are distinguished by their subdomain(s). I am attempting to make my test automation run on any of these environments (without having to change or duplicate the tests).

2
  • Can you write your own function that has a regular expression pattern that does the matching?
    – Yu Zhang
    Commented Dec 21, 2016 at 16:13
  • Yes but want to be 100% there isn't a more maintainable way beforehand.
    – Rebecca D.
    Commented Dec 21, 2016 at 16:14

1 Answer 1

0

One way that you can do this is by using:

browser
  .url(function(result) {
    //match result.value to expression here
  })

This is the best way I've been able to get the URL and doing any kind of matching with it.

1
  • @Rebecca-d were you able to find a solution?
    – Swagin9
    Commented Apr 4, 2017 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.