admin管理员组

文章数量:1317894

Chrome instance not getting started for selenium testing in github runner.

.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created: probably user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir

The exception is : .openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created: probably user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir 
Host info: host: 'road-runner-os023-m-nwx', ip: 'xxx'
Build info: version: '4.23.0', revision: '4df0a231af'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.19.0-41-generic', java.version: '17.0.14'
Driver info: .openqa.selenium.chrome.ChromeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--ignore-certificate-errors, --no-sandbox, --disable-dev-shm-usage, --user-data-dir=/tmp/chrome..., --disable-setuid-sandbox, --no-zygote, --start-maximized, --window-size=1920,1080, --headless=old, --disable-gpu, --window-size=1920,1080, --start-maximized], binary: /usr/bin/google-chrome, excludeSwitches: [enable-automation], extensions: [], prefs: {credentials_enable_service: false, profile.password_manager_enabled: false}, useAutomationExtension: false}}]}]

Attempted solution(didnt work):

options.addArguments("--user-data-dir=/tmp/chrome-user-data-dir");

  run: |
    export USER_DATA_DIR="/tmp/chrome-user-data-dir"
    mkdir -p "$USER_DATA_DIR"
    echo "USER_DATA_DIR=$USER_DATA_DIR" >> $GITHUB_ENV  

Using below to start chrome session

driver = new ChromeDriver(options);

Chrome instance not getting started for selenium testing in github runner.

.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created: probably user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir

The exception is : .openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created: probably user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir 
Host info: host: 'road-runner-os023-m-nwx', ip: 'xxx'
Build info: version: '4.23.0', revision: '4df0a231af'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.19.0-41-generic', java.version: '17.0.14'
Driver info: .openqa.selenium.chrome.ChromeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--ignore-certificate-errors, --no-sandbox, --disable-dev-shm-usage, --user-data-dir=/tmp/chrome..., --disable-setuid-sandbox, --no-zygote, --start-maximized, --window-size=1920,1080, --headless=old, --disable-gpu, --window-size=1920,1080, --start-maximized], binary: /usr/bin/google-chrome, excludeSwitches: [enable-automation], extensions: [], prefs: {credentials_enable_service: false, profile.password_manager_enabled: false}, useAutomationExtension: false}}]}]

Attempted solution(didnt work):

options.addArguments("--user-data-dir=/tmp/chrome-user-data-dir");

  run: |
    export USER_DATA_DIR="/tmp/chrome-user-data-dir"
    mkdir -p "$USER_DATA_DIR"
    echo "USER_DATA_DIR=$USER_DATA_DIR" >> $GITHUB_ENV  

Using below to start chrome session

driver = new ChromeDriver(options);

Share Improve this question asked Jan 22 at 15:32 AmreshAmresh 3831 gold badge6 silver badges16 bronze badges 4
  • try without setting the user-data-dir. It'll automatically create a temporary profile for use. If that fails, it's probably a permissions issue. – browsermator Commented Jan 22 at 20:06
  • Thanks for reply. Yes it was earlier setting without use of user-data-dir. It returned the same error. Hence posted the query here.. – Amresh Commented Jan 23 at 3:34
  • I believe its related to this github/actions/runner-images/issues/10636 – Keith Commented Jan 23 at 18:35
  • @Keith, Please try using headless with chromeoptions. – Amresh Commented Jan 23 at 18:46
Add a comment  | 

1 Answer 1

Reset to default 2

I am able to resolve by setting headless mode. Earlier I used headless=old.

Just simple setting

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--headless");
WebDriver driver = new ChromeDriver(chromeOptions);

本文标签: