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?
ChromeDriver does automatically assign a debugger port to chrome. You have multiple options in this scenario, namely:
Start your protractor instance first, navigate to chrome://version and parse --remote-debugging-port. Then pass this value to puppeteer.connect
Start a protractor instance in a beforeLaunch statement (or directly before exporting the configuration). You can then pass the launch port to chromedriver like this
capabilities: { browser: "chrome", chromeOptions: { debuggerAddress: "<your address>" } }
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.