test <input type="hidden"> will block the testcase
See original GitHub issueThis is my view, I want to test.
<h1>Request Group Rate</h1>
<form>
<input type="hidden" name="referrer">
Name: <input type="text" id="fieldName" name="name"><br>
Group size: <input type="text" name="groupSize"><br>
Email: <input type="email" name="email"><br>
<input type="submit" value="Submit">
</form>
<script>
$(document).ready(function() {
/* document.referrer: Returns the URI of the page that links to this page */
$('input[name="referrer"]').val(document.referrer);
});
</script>
I wrote my test like this:
var Browser = require('zombie'),
assert = require('chai').assert;
var browser;
suite('Cross-Page Tests', function() {
setup(function() {
browser = new Browser();
});
test('requesting a group rate quote from the hood river tour page ' +
'should populate the referrer field', function(done) {
var referrer = 'http://localhost:3000/tours/hood-river';
browser.visit(referrer, function() {
browser.clickLink('.requestGroupRate', function() {
browser.assert.input('form input[name="referrer"]', referrer);
done();
});
});
});
then, I run the test, I found the test will block at ** browser.assert.input(‘form input[name=“referrer”]’, referrer); ** (I annotate this line, and the test runs OK).
My package.son:
{
"name": "meadowlark",
"version": "1.0.0",
"description": "A travel website",
"main": "meadowlark.js",
"scripts": {
"test": "grunt"
},
"repository": {
"type": "git",
"url": "https://github.com/zwb-ict/meadowlark.git"
},
"keywords": [
"node"
],
"author": "zwb.ict@gmail.com",
"license": "MIT",
"bugs": {
"url": "https://github.com/zwb-ict/meadowlark/issues"
},
"homepage": "https://github.com/zwb-ict/meadowlark",
"dependencies": {
"express": "^4.12.3",
"express-handlebars": "^2.0.0"
},
"devDependencies": {
"chai": "^2.2.0",
"grunt": "^0.4.5",
"grunt-contrib-jshint": "^0.11.2",
"grunt-exec": "^0.4.6",
"grunt-istanbul": "^0.5.0",
"grunt-mocha-test": "^0.12.7",
"istanbul": "^0.3.13",
"mocha": "^2.2.4",
"zombie": "^3.0.0"
}
}
Issue Analytics
- State:
- Created 8 years ago
- Comments:5
Top Results From Across the Web
Introducing: Hidden Test Cases - by John Kelly
One good way to prevent students from cheating the system is to hide inputs and outputs to the test cases. This prevents the...
Read more ><input type="hidden"> - HTML: HyperText Markup Language
The <input> element's value attribute holds a string that contains the hidden data you want to include when the form is submitted to...
Read more >Issues with matching values in forms, and hidden fields #1017
Hello, I am currently using rspec for testing our application. This is the HTML that we are testing against:
Read more >Best way to test input value in dom-testing-library or react ...
One final alternative for testing the value is to find the input by role. This won't work in your example's case unless you...
Read more >Preventing tampering with hidden inputs
Since they are not rendered visible, hidden inputs are sometimes erroneously perceived as safe. But similar to session cookies, hidden form inputs store...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have the same problem, I still don’t know why the document.referrer stays empty, but I managed to get the referrer from headers using this:
I think the problem is coming from Zombie itself because when trying this manually in browser, document.referrer is set correctly!
Has the fix been merged or not? I am having a similar problem with document.referrer returning an empty string.