Reputation: 85
I'm new to JavaScript, I'm trying to make a bot that interacts with a web page and automates some steps such as clicking some buttons. I wanted to use for example document.getElementById('button').Click
but the command should refer to a specific url of a page. If you can, do some code examples.
Upvotes: 1
Views: 3936
Reputation: 1095
To run this command you can create some code using selenium or puppeteers. This enables a webpage to run on backend end, then to do some stuff like cliking button if you want. It's pretty hard to define how you want to do that, but this is en example of puppeteers in javascript (Node JS)
const puppeteer = require("puppeteer")
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://myurl');
await page.evaluate(() => {
//do something on the page
});
})();
don't forget to install pupeteers with npm install
and to add some sleep
functions if the page takes too long to render (the page can be available but the js of the page didn't finish his work so you need to wait)
Upvotes: 1