Monday 26 August 2019

Why my Google Chrome is being opened through selenium webdriver in my puppeteer app?

Hi all , i am trying to do automation through puppeteer lib, i am trying to automate logging in into a website in chrome browser and doing some stuff there. So my problem is that i am putting google chrome's path in my code ( it is a right path ) but when i am running the code it works through selenium webdriver i guess. ( NOTE: I have other projects where i am doing scraping and that's why i am using selenium ). So do you know any way that i can use to make my code work though my actual browsers and not with selenium ? I have searched every forum in SO and everywhere but can't find even sufficient problem .Here is my code.const puppeteer = require('puppeteer-core'); //const email = document.querySelector('#email'); //const pass = document.querySelector('#pass'); async function login() { const browser = await puppeteer.launch({headless: false, executablePath: '/opt/google/chrome/google-chrome' }); // const context = await browser.createIncognitoBrowserContext(); const page = await browser.newPage(); // Focus input await page.goto('https://www.facebook.com'); await page.click('#email'); await page.keyboard.type('SOMELOGIN'); // Focus password await page.click('#pass'); await page.keyboard.type('SOMEPASS'); // Get login button and submit it const loginButton = await page.$('#loginbutton input'); await loginButton.click(); await loginButton.click(); await page.goto('https://www.facebook.com'); await page.click('#js_w > div._i-o._2j7c > div > div._7r84 > div.clearfix._ikh > div._4bl9 > div > div > div > div'); await page.keyboard.type('https://www.kickstarter.com/projects/boazinstruments/boaz-one-one-modular-guitar-50-combinations?ref=section-homepage-projectcollection-2-staff-picks-popular'); const postbutton = await page.$('#js_w > div._1j2v > div._2dck._1pek._4-u3 > div._45wg._69yt > button'); await postbutton.click(); // Wait if we get redirected to login await page.waitForNavigation() browser.close(); } login(); And yes, using puppeteer-core is mandatory , due to my project i can't use just puppeteer.

Submitted August 26, 2019 at 03:48PM by Grigor_1

No comments:

Post a Comment