Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.openqa.selenium.InvalidArgumentException: invalid argument: user data directory is already in use #3

Open
kazurayam opened this issue Feb 9, 2020 · 5 comments

Comments

@kazurayam
Copy link
Owner

The following error occures when WebDriverFactory tries to open a Chrome browser specifying a User profile or directory AND another Chrome is already running with the User profile or directory.

Test Cases/main/example/usingChromeDriverFactory/how_to_start_Gmail_without_Login_interaction FAILED.
Reason:
org.openqa.selenium.InvalidArgumentException: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'urayama-no-MacBook-Air.local', ip: 'fe80:0:0:0:88b:9cd6:7e98:7adc%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '1.8.0_181'
Driver info: driver.version: ChromeDriver
remote stacktrace: 0   chromedriver                        0x0000000108762ec9 chromedriver + 3837641
1   chromedriver                        0x00000001086fccc3 chromedriver + 3419331
2   chromedriver                        0x00000001084711ef chromedriver + 750063
3   chromedriver                        0x00000001083cf25e chromedriver + 86622
4   chromedriver                        0x00000001083fdff3 chromedriver + 278515
5   chromedriver                        0x00000001083fae33 chromedriver + 265779
6   chromedriver                        0x00000001083d4c3d chromedriver + 109629
7   chromedriver                        0x00000001083d5bd5 chromedriver + 113621
8   chromedriver                        0x0000000108724a5f chromedriver + 3582559
9   chromedriver                        0x00000001087319ea chromedriver + 3635690
10  chromedriver                        0x0000000108731787 chromedriver + 3635079
11  chromedriver                        0x00000001087083d9 chromedriver + 3466201
12  chromedriver                        0x00000001087322a7 chromedriver + 3637927
13  chromedriver                        0x000000010871a867 chromedriver + 3541095
14  chromedriver                        0x0000000108747ec4 chromedriver + 3727044
15  chromedriver                        0x0000000108768f27 chromedriver + 3862311
16  libsystem_pthread.dylib             0x00007fff7120e661 _pthread_body + 340
17  libsystem_pthread.dylib             0x00007fff7120e50d _pthread_body + 0
18  libsystem_pthread.dylib             0x00007fff7120dbf9 thread_start + 13

	at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
	at 

This error is inevitable, but not so much easy to understand and see how to get work-around.

If possible, want to check if collision is to happen, and emit more friendly message.

@kazurayam
Copy link
Owner Author

This case as well

02-13-2020 09:38:50 午前 Test Cases/test/com.kazurayam.ks.webdriverfactory/WebDriverFactoryTestRunner

Elapsed time: 16.471s

Test Cases/test/com.kazurayam.ks.webdriverfactory/WebDriverFactoryTestRunner FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: These following reason:
 [
	org.openqa.selenium.InvalidArgumentException: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
	Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
	System info: host: 'N19-D267', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
	Driver info: driver.version: WebDriverFactory$newWebDriver
	remote stacktrace: Backtrace:
		Ordinal0 [0x00D0A113+1548563]
		Ordinal0 [0x00C8DDA1+1039777]
		Ordinal0 [0x00C0E485+517253]
		Ordinal0 [0x00B9CB4B+52043]
		Ordinal0 [0x00BBB797+178071]
		Ordinal0 [0x00BBB59D+177565]
		Ordinal0 [0x00BB95FB+169467]
		Ordinal0 [0x00BA160A+71178]
		Ordinal0 [0x00BA2690+75408]
		Ordinal0 [0x00BA2629+75305]
		Ordinal0 [0x00CA71B7+1143223]
		GetHandleVerifier [0x00DA2B46+507814]
		GetHandleVerifier [0x00DA2864+507076]
		GetHandleVerifier [0x00DA9F47+537511]
		GetHandleVerifier [0x00DA3402+510050]
		Ordinal0 [0x00C9F29C+1110684]
		Ordinal0 [0x00CA938B+1151883]
		Ordinal0 [0x00CA94F3+1152243]
		Ordinal0 [0x00CA83F5+1147893]
		BaseThreadInitThunk [0x75770419+25]
		RtlGetAppContainerNamedObjectPath [0x7737662D+237]
		RtlGetAppContainerNamedObjectPath [0x773765FD+189]
	
		at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
		at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
		at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
		at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
		at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
		at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
		at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
		at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
		at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
		at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
		at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
		at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:147)
		at com.kazurayam.ks.webdriverfactory.chrome.ChromeDriverFactoryImpl.execute(ChromeDriverFactoryImpl.groovy:95)
		at com.kazurayam.ks.webdriverfactory.chrome.ChromeDriverFactoryImpl.openChromeDriverWithProfile(ChromeDriverFactoryImpl.groovy:165)
		at com.kazurayam.ks.webdriverfactory.chrome.ChromeDriverFactoryImpl$openChromeDriverWithProfile$0.call(Unknown Source)
		at com.kazurayam.ks.webdriverfactory.WebDriverFactory.newWebDriver(WebDriverFactory.groovy:46)
		at com.kazurayam.ks.webdriverfactory.WebDriverFactory$newWebDriver$0.callStatic(Unknown Source)
		at com.kazurayam.ks.webdriverfactory.WebDriverFactory.newWebDriver(WebDriverFactory.groovy:39)
		at com.kazurayam.ks.webdriverfactory.WebDriverFactory$newWebDriver.call(Unknown Source)
		at com.kazurayam.ks.webdriverfactory.WebDriverFactoryTest.test_newWebDriver_ChromeDriver_withProfile(WebDriverFactoryTest.groovy:45)
		at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
		at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
		at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
		at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
		at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
		at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
		at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
		at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
		at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
		at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
		at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
		at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
		at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
		at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
		at org.junit.runners.Suite.runChild(Suite.java:128)
		at org.junit.runners.Suite.runChild(Suite.java:27)
		at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
		at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
		at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
		at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
		at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
		at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
		at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
		at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
		at org.junit.runner.JUnitCore.run(JUnitCore.java:105)
		at com.kazurayam.junit4ks.JUnitCustomKeywords$_runWithJUnitRunner_closure1.doCall(JUnitCustomKeywords.groovy:138)
		at com.kazurayam.junit4ks.JUnitCustomKeywords$_runWithJUnitRunner_closure1.doCall(JUnitCustomKeywords.groovy)
		at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:68)
		at com.kms.katalon.core.keyword.internal.KeywordMain$runKeyword.call(Unknown Source)
		at com.kazurayam.junit4ks.JUnitCustomKeywords.runWithJUnitRunner(JUnitCustomKeywords.groovy:134)
		at com.kazurayam.junit4ks.JUnitCustomKeywords$runWithJUnitRunner$0.callStatic(Unknown Source)
		at com.kazurayam.junit4ks.JUnitCustomKeywords.runWithJUnitRunner(JUnitCustomKeywords.groovy:215)
		at com.kazurayam.junit4ks.JUnitCustomKeywords$runWithJUnitRunner.callStatic(Unknown Source)
		at WebDriverFactoryTestRunner.run(WebDriverFactoryTestRunner:5)
		at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
		at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
		at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
		at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
		at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
		at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
		at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
		at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
		at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
		at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
		at TempTestCase1581554327449.run(TempTestCase1581554327449.groovy:23)
	]
	at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:50)
	at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy)
	at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:23)
	at com.kms.katalon.core.keyword.internal.KeywordMain$stepFailed$0.call(Unknown Source)
	at com.kazurayam.junit4ks.JUnitCustomKeywords$_runWithJUnitRunner_closure1.doCall(JUnitCustomKeywords.groovy:150)
	at com.kazurayam.junit4ks.JUnitCustomKeywords$_runWithJUnitRunner_closure1.doCall(JUnitCustomKeywords.groovy)
	at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:68)
	at com.kms.katalon.core.keyword.internal.KeywordMain$runKeyword.call(Unknown Source)
	at com.kazurayam.junit4ks.JUnitCustomKeywords.runWithJUnitRunner(JUnitCustomKeywords.groovy:134)
	at com.kazurayam.junit4ks.JUnitCustomKeywords$runWithJUnitRunner$0.callStatic(Unknown Source)
	at com.kazurayam.junit4ks.JUnitCustomKeywords.runWithJUnitRunner(JUnitCustomKeywords.groovy:215)
	at com.kazurayam.junit4ks.JUnitCustomKeywords$runWithJUnitRunner.callStatic(Unknown Source)
	at WebDriverFactoryTestRunner.run(WebDriverFactoryTestRunner:5)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1581554327449.run(TempTestCase1581554327449.groovy:23)

@kazurayam
Copy link
Owner Author

kazurayam commented Feb 13, 2020

SeleniumでChromeのユーザープロファイルを指定しつつ同時に自分もChromeを使う方法
https://qiita.com/Hidenatsu/items/e43ba04b4b5f710784e6

どうやら今起動しているChromeが参照しているユーザプロファイルがあるフォルダと同じフォルダをSeleniumで指定することはできないようです。

うん、そのようですね。

このままでは、SeleniumからChromeを起動する度に、いつも使っているChromeを閉じなければなりません。

うん、そのとおりですね。

めんどくさいです
そこで、ユーザプロファイルが置かれるフォルダを新しく作って、そちらを参照してみるとうまくいきました。

Hidenatsuさんはその回避方法でいいでしょうが、わたしとしては、その方法がとりにくい。手動で作ったChromeのプロファイルをそのままSeleniumに参照させたいから。

ということは、わたしの場合、手動で開いたChromeをぜんぶ閉じてからSeleniumテスト(=Katalon Studioテスト)を実行せよという条件を付けることはいたしかたないと考えるべき。Exceptionメッセージのなかに「Chromeブラウザをぜんぶ閉じてからやりなおしなさい」というメッセージを表示して補いとするか。

@kazurayam
Copy link
Owner Author

Exceptionのメッセージが

or don't use --user-data-dir

といっているのを真に受けて、--user-data-dir=xxxx を指定するのを止めてみた。そしたらExceptionが発生しなくなった。

これでいいんじゃないの?

kazurayam pushed a commit that referenced this issue Feb 13, 2020
…nvalid argument: user data directory is already in use
@kazurayam
Copy link
Owner Author

I was wrong.
I removed --user-data-dir=xxx and tried --- bad result. Unable to launch Chrome with "Katalon" profile.

@kazurayam
Copy link
Owner Author

@kazurayam kazurayam reopened this Feb 24, 2020
kazurayam added a commit that referenced this issue Feb 25, 2020
… a temp directory in order to work-around the contention of User Data directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant