Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github login automated #4

Merged
merged 3 commits into from
Oct 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions login-github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules

*.log
*.error.log
40 changes: 40 additions & 0 deletions login-github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# How to use this automation ?

Download code or clone repo

```bash

git clone https://github.com/vivek80801/Python-Automations.git

```

then navigate to folder

```bash

cd Python-Automations/login-github/

```

Now install all dependency

```bash

npm install

```

then run the script

```bash

node index.js

```

## Requiments

You should `nodejs` installed in your device.

If You haven't yet go to [nodejs org](https://nodejs.org)

Binary file added login-github/example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions login-github/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const puppeteer = require("puppeteer");
const readline = require("readline");

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});

let userName = "";
let password = "";

const ask_user_name = () => {
return new Promise((resolve, reject) => {
rl.question("What is your user name ? \n ", (answer) => {
userName = answer;
console.log(`your user name is ${userName}\n`);
resolve();
});
});
};

const ask_password = () => {
return new Promise((resolve, reject) => {
rl.question("What is your password ? \n ", (answer) => {
password = answer;
console.log(`your password is ${password}\n`);
resolve();
});
});
};

(async () => {
try {
await ask_user_name();
await ask_password();
rl.close();
const browser = await puppeteer.launch({
headless: false,
args: ["--start-maximized"],
});
const page = await browser.newPage();
await page.setViewport({ width: 1366, height: 768 });
await page.goto("https://github.com/login", {
waitUntil: "networkidle0",
timeout: 0,
});
await page.waitForSelector("#login_field");
await page.waitForSelector("#password");
await page.waitForSelector(".btn.btn-primary.btn-block");
await page.type("#login_field", userName, { delay: 250 });
await page.type("#password", password, { delay: 250 });
await page.click(".btn.btn-primary.btn-block");
} catch (error) {
console.log(error.message);
}
})();
Loading