srikanthD
srikanthD

Reputation: 11

Protractor | Linux Machine | WebDriverError: unknown error: cannot create temp dir for user data dir

I am using Protractor and newbie to it I have installed protractor using npm i -g protractor webdriver-manager update webdriver-manager start

when I run protractor conf_master.js I am getting following error

[chrome #01-1] [20:01:12] I/local - Starting selenium standalone server...
[chrome #01-1] [20:01:16] I/local - Selenium standalone server started at http://10.289.122.156:21199/wd/hub
[chrome #01-1]
[chrome #01-1] /data/home/aflsexchange/node-v10.15.3-linux-x64/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:546
[chrome #01-1]         throw new ctor(message);
[chrome #01-1]               ^
[chrome #01-1] WebDriverError: unknown error: cannot create temp dir for user data dir
[chrome #01-1] Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
[chrome #01-1] System info: host: '<myurl>', ip: '10.247.189.139', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-1062.1.2.el7.x86_64', java.version: '1.8.0_161'
[chrome #01-1] Driver info: driver.version: unknown
[chrome #01-1] remote stacktrace: #0 0x55f67c8507e9 <unknown>
[chrome #01-1]

I am using Linux machine. Please let me know about the solution

Upvotes: 1

Views: 3450

Answers (2)

rafalkasa
rafalkasa

Reputation: 2021

Usually this problem is related to the permissions please use custom user-data-dir below you will find small example solved problem for me

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--profile-directory=Default')
chrome_options.add_argument('--user-data-dir=~/.config/google-chrome')

driver = webdriver.Chrome(options=chrome_options)
url = 'https://www.google.com'
driver.get(url) 
get_url = driver.current_url 
print(get_url)

Upvotes: 0

undetected Selenium
undetected Selenium

Reputation: 193108

This error message...

WebDriverError: unknown error: cannot create temp dir for user data dir

...implies that the ChromeDriver was unable to create a temporary directory while trying to initiate/spawn a new WebBrowser i.e. Chrome Browser session.

This error can occur due to different configuration issues or incompatibility between the version of the binaries you are using.


Solution

Ensure that:

  • Node is updated using the Package Manager.
  • Execute your @Test as non-root user (preferably with root/admin priviledge).
  • JDK is upgraded to current levels JDK 8u222.
  • Selenium is upgraded to current levels Version 3.141.59.
  • ChromeDriver is updated to current ChromeDriver v78.0 level.
  • Chrome is updated to current Chrome Version 78.0 level. (as per ChromeDriver v78.0 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • (WindowsOS only) Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.
  • (LinuxOS only) Free Up and Release the Unused/Cached Memory in Ubuntu/Linux Mint before and after the execution of your Test Suite.
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

Upvotes: 1

Related Questions