Reputation: 33
Please consider me a noob as I am still learning puppeteer.
I am writing a test to verify that the following input field has the readonly property to stop end-users from modifying it.
<input readonly id="serverUrl" type="text" value="https://mytestservice.com/">
I have tried several methods to achieve this but my methods are returning either undefined or false e.g.
let inputField = await page.$('#serverUrl')
const is_readonly = await (await inputField.getProperty("readonly")).jsonValue();
The above returns undefined
.
Since I have fetched a radio button's disabled property using the following method, I thought I can do the same with the input field to verify the readonly property, by using the following:
const is_readonly = await page.$('#serverUrl[readonly]') !== null;
This resulted in false
for the above-mentioned input field.
I have then run the same method on another field that does not have the readonly property the result for that field was also false.
is_readyonly value is : false
Can someone please elaborate on what I am doing wrong or how to resolve it, any help will be greatly appreciated, please?
Upvotes: 0
Views: 894
Reputation: 8972
Your problem is that the property is specified as readOnly
instead of readonly
. From the specification:
The readOnly IDL attribute must reflect the readonly content attribute
So you need to spell it with a capital O:
const is_readonly = await (await inputField.getProperty("readOnly")).jsonValue();
Upvotes: 1