但是您可以轻松地执行以下操作:需要请求"库,对要在Selenium测试中打开的网页进行请求,并确认响应状态代码等于200:const request = require('request');request('http://stackoverflow.com', (error, response, body) => { browser.assert.equal(response.statusCode, 200);});how do I check the HTTP status code using nightwatch.js? I tried browser.url(function (response) { browser.assert.equal(response.statusCode, 200); });but of course that does not work. 解决方案 Actually there is no way yet to get the response status of the page using Selenium (https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/141)But what you can easily do is require "request" library, make your request to the webpage you want to open in your Selenium tests and validate that response status code equals 200:const request = require('request');request('http://stackoverflow.com', (error, response, body) => { browser.assert.equal(response.statusCode, 200);}); 这篇关于使用Nightwatch检查HTTP状态代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-29 03:22
查看更多