I have a PhantomJS script based on this one: http://code-epicenter.com/how-to-login-amazon-using-phantomjs-working-example/
It works very well, I can, for example, populate the login page and click on the "submit" button with code that looks like this:
function(){
console.log('Step 3');
page.evaluate(function() {
document.getElementById("username-pulldown").value="username";
document.getElementById("password-pulldown").value="password";
document.getElementById("login-pulldown" ).click();
});
},
Later-on, however, I try to execute this:
function(){
console.log('Step 7');
page.evaluate(function(){
document.getElementById("content_text").value += "SomeTextIWannaAdd";
//console.log(document.documentElement.innerHTML);
document.getElementByName("button");
});
},
I get this error message:
Step 7
ERROR: TypeError: undefined is not a function (evaluating
'document.getElementByName("button")')
TRACE:
-> undefined: 3
-> : 8
phantomjs://code/EditWiki.js:48 in onError
The html element i want to get looks as follows:
<button name="button" type="submit" class="button -highlight -with-icon icon-checkmark">Save</button>
The rest of the innerHTML: https://pastebin.com/j5cCDxEU