Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
Assert a script is present on the page using nightwatchjs

I'm using nightwatchjs and trying to test whether a javascript script is present on a page or not.

Below is the html;

enter image description here

and I need to test that this is present on a particular page.

I understand that I could use Xpath (for example) and simply assert the following;

browser.assert.elementPresent('/html/head/script[10]/text()')

However, this isn't really practical as scripts are often inserted before this script in due course which would fail the test due to the xpath of this script changing.

So, is there a way that I can pick out a certain part of this inserted javascript script (highlighted in yellow in the image above) and assert against this, rather than the whole script? This would then make the test far less brittle.

Many thanks

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!