Tuesday, March 21, 2017

Wordpress Upload Plugin Form Will Not Activate In Headless Browser

Leave a Comment

I am working on a little project where PhamtomJS will log into my site and upload a plugin to it. I almost have it, except for one strange problem. Although the file.upload portion of my code works perfectly, the button to download the plugin remains disabled. Here is a picture rendered from Phantom:

Screenshot

As you can see, the button is still disabled. So when I try to click it using the getElementById() method, it will not work. Nor will it work if I try to submit the form by doing:

document.querySelector('form[action*="/wp-admin/update.php?action=upload-plugin"]').submit() 

I have also tried enabling the button manually and then clicking it via Javascript, but that has not worked either. Any ideas?

EDIT When trying to pull the outer HTML of the button, I typed the following into console:

console.log(document.querySelector('#install-plugin-submit').outerHTML) 

The result of this code was the following:

<input type="submit" name="install-plugin-submit" id="install-plugin-submit" class="button" value="Install Now"> 

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment