0

I have selenium scripts to run on docker container selenium grid that were written before I join this project. due to the docker I don't have access to view the browser while running the scripts. And when scripts fail its very hard to debug. Can someone help me how to modify the below conf.js file to run my scripts locally for debugging.

Conf.js

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;

const log = require('loglevel');
const util = require('@raven/common-protractor-test-utils');
const { ExpectedConditions } = require('protractor');

 require('dotenv').config({ path: '.local.env' })
 
var testOutputDir = './test_output/';
let peregrineUrl = util.functionalTestBaseUrl(
  'https://ea-webapp-int-raven.ocp-nonprod/'
);
let domainName = util.domainName;
exports.config = {
  directConnect: true, // Set to true for local testing, or provide a link to a running selenium grid.
  specs: ['e2e/**/mailbox-test.js', 'e2e/**/email-dumps-test.js'],
  capabilities: {
    browserName: 'chrome',
    acceptInsecureCerts: true,
    'goog:chromeOptions': {
      w3c: false,
      args: [
        '--no-sandbox',
        // '--headless',
        '--disable-gpu',
        '--window-size=1200,1200',
        '--allow-insecure-localhost',
        '--allow-running-insecure-content',
        '--ignore_ssl',
        '--user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36',
      ],
    },
  },

  allScriptsTimeout: 600000,
  baseUrl: peregrineUrl,
  framework: 'jasmine',

  jasmineNodeOpts: {
    isVerbose: true,
    showColors: true,
    includeStackTrace: true,
    defaultTimeoutInterval: 600000,
    stackTrace: true
  },
onPrepare: async () => {
    /* Set Log Level */
    log.setLevel('INFO');
    log.info('Base URL: ' + peregrineUrl);
    log.info('Domain Name: ' + domainName);
    browser.ignoreSynchronization = true;
    const ec = protractor.ExpectedConditions;

    /* Set up the test directory. */
    util.mkdirs(testOutputDir);

    console.time('Peregrine Load Time');

    await browser.get(peregrineUrl);
browser.driver.sleep(3000);
await username_area.sendKeys('rv-peregrine-test-user');
    await password_area.sendKeys(process.env.SELENIUM_SERVICE_PASSWORD);
    await agree_button.click();
    await login_button.click();
 },
};

When I try to change directConnect: ture and disable --headless to run locally I am able to see the chrome browser launched but the application opened. This is the trace from my console

   [21:28:19] I/launcher - Running 1 instances of WebDriver
[21:28:19] I/direct - Using ChromeDriver directly...

DevTools listening on ws://127.0.0.1:51650/devtools/browser/bf44c6c7-72a6-49e5-ab80-b13139ce9005
[15808:15796:0115/212822.298:ERROR:url_util.cc(414)] Invalid pattern javascript://
[15808:4128:0115/212826.609:ERROR:chrome_browser_main_extra_parts_metrics.cc(227)] START: ReportBluetoothAvailability(). If you don't see the END: message, this is crbug.com/1216328.
[15808:4128:0115/212826.610:ERROR:chrome_browser_main_extra_parts_metrics.cc(230)] END: ReportBluetoothAvailability()
[15808:4128:0115/212826.611:ERROR:chrome_browser_main_extra_parts_metrics.cc(235)] START: GetDefaultBrowser(). If you don't see the END: message, this is crbug.com/1216328.
[15808:15796:0115/212826.611:ERROR:device_event_log_impl.cc(214)] [21:28:26.611] USB: usb_device_handle_win.cc:1050 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[15808:15796:0115/212826.613:ERROR:device_event_log_impl.cc(214)] [21:28:26.613] USB: usb_device_handle_win.cc:1050 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[15808:4128:0115/212826.672:ERROR:chrome_browser_main_extra_parts_metrics.cc(239)] END: GetDefaultBrowser()
[15808:15796:0115/212826.687:ERROR:device_event_log_impl.cc(214)] [21:28:26.688] Bluetooth: bluetooth_adapter_winrt.cc:1206 Getting Radio failed. Chrome will be unable to change the power state by itself.
[15808:15796:0115/212826.730:ERROR:device_event_log_impl.cc(214)] [21:28:26.730] Bluetooth: bluetooth_adapter_winrt.cc:1284 OnPoweredRadioAdded(), Number of Powered Radios: 1
[15808:15796:0115/212826.732:ERROR:device_event_log_impl.cc(214)] [21:28:26.732] Bluetooth: bluetooth_adapter_winrt.cc:1299 OnPoweredRadiosEnumerated(), Number of Powered Radios: 1

Thanks in advance

Vin
  • 165
  • 2
  • 12
  • Does this answer your question? [InvalidArgumentException: Message: invalid argument: user data directory is already in use error using --user-data-dir to start Chrome using Selenium](https://stackoverflow.com/questions/59987080/invalidargumentexception-message-invalid-argument-user-data-directory-is-alre) – Ouroborus Jan 15 '22 at 22:57
  • Hi @Ouroborus, Thanks for your reply. I tried that already but still didn't help me. also I have updated my code and one thing the change was I closed all my chrome browsers and so the browser is launched this time. But its not navigating to the app. I have provided the console in the above post. – Vin Jan 16 '22 at 02:37
  • How do you access the app UI locally when its running inside the container? I see you have a baseUrl variable set near the top of the script. Perhaps you need to change that to something that is on localhost? However you access the UI when its running locally in the container, that is the url you want to use. The one you are currently using does not look like localhost. – tehbeardedone Jan 20 '22 at 15:21
  • @tehbeardedone, When I use DirectConnect is true then I assume the script runs locally and not in the container. I even see the chrome opened but not navigated to that url that was mentioned in my onPrepare section. – Vin Jan 24 '22 at 14:12
  • I noticed you also have `--disable-gpu` set in the capabilities but I don't think that would cause this issue. What is returned from `util.functionalTestBaseUrl()`? What is the value of `peregrineUrl` if you log it to the console? I'm just trying to understand why you need that util function instead of just setting `baseUrl: 'https://ea-webapp-int-raven.ocp-nonprod/' ` in the config? – tehbeardedone Jan 25 '22 at 19:30

0 Answers0