1
1
mirror of https://github.com/ariya/phantomjs.git synced 2024-08-15 15:50:34 +03:00
phantomjs/examples/useragent.js
Zachary T Jones 9bbd1ab0a3 Update selector in useragent example to prevent TypeError
The DOM structure of the page that is retrieved by useragent.js
has changed since the example was last updated, and the selector
for the user agent value no longer exists. This causes a TypeError
to be output to the user when running the example. This updates
the example to use a selector that exists on the page.

https://github.com/ariya/phantomjs/issues/15392
2018-06-02 01:09:14 -07:00

16 lines
490 B
JavaScript

"use strict";
var page = require('webpage').create();
console.log('The default user agent is ' + page.settings.userAgent);
page.settings.userAgent = 'SpecialAgent';
page.open('http://www.httpuseragent.org', function (status) {
if (status !== 'success') {
console.log('Unable to access network');
} else {
var ua = page.evaluate(function () {
return document.getElementById('qua').value;
});
console.log(ua);
}
phantom.exit();
});