0

I am currently experimenting something, and I became to have to click a button on a website which I didn't make, automatically using files made up of javascript and other web languages.

I read this one: How do I programmatically click a link with javascript?

But if I want to auto-click a website which I didn't make, so I can't get access to the website's files. Then, should (or can) I load the website's .php or .html and attach my snippets which contain document.getElementById('yourLinkID').click(); ?

If I can load the website's files, and attach my code and make it run, How can I do that? Or is there other possible ways?

Since I try to click a site whose files aren't accessible, I can't figure out how can I click button

2
  • Open the page in your browser (let's say Google Chrome), press F12 to open browser console and run the following: document.getElementById('yourLinkID').click()
    – leo.fcx
    Feb 3, 2016 at 14:28
  • You can try to load the external page in an iframe. Via the iFrame-Handle you may get access to the dom-elements.
    – Fearodin
    Feb 3, 2016 at 14:30

1 Answer 1

0

There are three ways I can think of:

  1. Open the 'developer tools' in your browser, and copy & paste your snippets there.
  2. Create a Chrome plugin to attach the snippets and click the link.
  3. Run something like Selenium ChromeDriver, and instruct it to go to the site mentioned and execute the document.getElementByid('yourLinkID').click()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.