angular / protractor

E2E test framework for Angular apps
http://www.protractortest.org
MIT License
8.75k stars 2.31k forks source link

puppeteer using protractor web driver chrome session #5331

Open vijaychowthri opened 4 years ago

vijaychowthri commented 4 years ago

Am launching chrome using a protractor web-driver, in selenium address (http://localhost:4444), my remote debugging port (21222) in config file, is there a way to force to use the session in puppeteer for authentication, then same session I could use it for test execution using the protractor?

seleniumAddress: 'http://localhost:4444/wd/hub',

Config.js capability could be :

capabilities: { browserName: 'chrome', directConnect: true, chromeOptions: { 'useAutomationExtension' : false, 'binary': require('puppeteer').executablePath(), 'excludeSwitches': ['enable-automation'], args: [ '--incognito', '--remote-debugging-port=21222' ], } },

spec.js:

it('STEP#1 , Validate title', async function () { let browser = await puppeteer.connect({ headless: true, browserWSEndpoint: 'ws://localhost:21222' , });

const page = await browser.newPage(); ---< newtab ?? instad of page ?? > await page.authenticate({ username: user, password: password }); await page.setExtraHTTPHeaders({ 'Accept-Language': 'en-US,en;q=0.9', headless: 'true', });

await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36'); await page.goto("https://www.myapplication.org/info", { waitUntil: 'networkidle0' });

}) it('STEP#2 , Validate title', async function () { browser.driver.get('https://www.myapplication.org/info'); var foo = element(by.css('text-input#prodLine div p')); await expect(foo.getText()).toEqual('Inner text'); browser.sleep(10000); })

using same instance, i should able to execute rest of my test steps using a protractor.

josepmc commented 4 years ago

ChromeDriver does automatically assign a debugger port to chrome. You have multiple options in this scenario, namely: