Created
March 1, 2016 01:20
-
-
Save magemore/c935425d90b80a71c794 to your computer and use it in GitHub Desktop.
playing testing site with phantomjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('Loading a web page'); | |
var page = require('webpage').create(); | |
page.viewportSize = { width: 1000, height: 500 }; | |
page.clipRect = { | |
top: 0, | |
left: 0, | |
width: 1000, | |
height: 800 | |
}; | |
var url = 'http://www.example.com/admin/'; | |
var output = 'test.png'; | |
page.open(url, function (status) { | |
page.onLoadFinished = function(status) { | |
console.log('page loaded'); | |
page.onLoadFinished = null; | |
page.open('http://www.example.com/index.php/admincalltab/index/edit/id/1/', function (status) { | |
page.evaluate(function() { | |
jQuery(jQuery('table.data')[1]).find('tr:eq(2)').click(); | |
}); | |
console.log('popup with product details'); | |
setTimeout(function(){ | |
var r = page.evaluate(function() { | |
return jQuery('#fancybox-frame').contents(); | |
}); | |
console.log(r); | |
page.render(output); | |
phantom.exit(); | |
},2000); | |
}); | |
} | |
var eo = page.evaluate(function() { | |
// login | |
document.getElementById('username').value='admin'; | |
// password | |
document.getElementById('login').value='q1234e'; | |
// click submit | |
document.getElementsByTagName('input')[3].click(); | |
}); | |
//console.log(eo); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
run as:
phantomjs --web-security=no open.js
in order to access and manipulate iframe contents