Skip to content
This repository was archived by the owner on Nov 29, 2018. It is now read-only.

SafariDriver fails with "Expected data directory /Users/myusername/Library/Safari does not exist" message #5293

Closed
lukeis opened this issue Mar 4, 2016 · 12 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 4, 2016

Originally reported on Google Code with ID 5293

Before filing an issue, please read the page at
http://code.google.com/p/selenium/wiki/SeleniumHelp This contains lot of
information about how best to get help, and tells you what we need to know.

Still here? We know that bugs are frustrating and annoying things. We also
know that you've probably spent ages trying to figure out what's wrong. The
more information you give us now, the more likely it is that we'll be able
to help.

What steps will reproduce the problem?
1. new SafariDriver()

I see that there is no such directory on my machine. But I have Safari installed and
using it with Selenium-RC for a while now.


What is the expected output? What do you see instead?
Looking at the Java exception trace, I get the message that /Users/myuser/Library/Safari
does not exists, indeed it does not

that makes sense given this code in Safari extension classes:

 if (Platform.MAC.is(current)) {
      return new File("/Users/" + System.getenv("USER"), "Library/Safari");
    } 

Selenium version: 2.31
OS: Mac OS X 10.7.4
Browser: Safari
Browser version: 6.0


Please provide any additional information below. A sample reduced test
case, or a public URL that demonstrates the problem will intrigue our merry
band of Open Source developers far more than nothing at all: they'll be far
more likely to look at your problem if you make it easy for them!

Reported by binod80 on 2013-03-06 22:58:40

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Interesting.  You'll have to track down where the Safari data is on your machine for
me to fix this.  I use the SafariDriver on various machines ranging from 10.7 to 10.8.4,
and the Safari browser data is always in the same location.

Reported by jmleyba on 2013-03-07 04:21:48

  • Status changed: NeedsClarification
  • Labels added: Browser-Safari, Component-WebDriver
  • Labels removed: Status-Untriaged

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

It turns out that our company's dev machines don't have this directory. Instead Safari's
library directory is routed to a different location. 

I can run the tests on our automation machines which use local directories. 

If I am the sole person in the world to encounter this, I will be willing to work with
my systems team to resolve this (which will not be easy it seems), but at the same
time, are the Safaridriver team open to allowing system properties to override that
location, I can arrange for a detection of that alterantive location and inject the
location when I am starting Safaridriver.


such as

webdriver.safari.libDir=/SomeOtherLibDir

which would override Safaridriver's default location of 

new File("/Users/" + System.getenv("USER"), "Library/Safari");


Any chance of getting this feature in?

Thanks

Reported by binod80 on 2013-03-27 13:54:23

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

This issue was closed by revision 0617e5cb6361.

Reported by jmleyba on 2013-03-27 18:03:12

  • Status changed: Fixed

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Woah, that was a quick fix! Thanks very much. I will try to preview this with our stuff
and let you know.

Reported by binod80 on 2013-03-27 19:56:26

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Issue Persists for me. Although the machine does have Library/Safari directory. This
issue happens when running Selenium build.xml through Team City. However when It is
run manually it shows no error what so ever. 

This is the exact warning message. 
---------------------------------------------------------
java.lang.IllegalStateException: The expected Safari data directory does not exist:
/Users/root/Library/Safari
    at com.google.common.base.Preconditions.checkState(Preconditions.java:176)
    at org.openqa.selenium.safari.SafariDriverExtension.getInstallDirectory(SafariDriverExtension.java:166)
    at org.openqa.selenium.safari.SafariDriverExtension.install(SafariDriverExtension.java:199)
    at org.openqa.selenium.safari.SafariDriverCommandExecutor.start(SafariDriverCommandExecutor.java:87)
    at org.openqa.selenium.safari.SafariDriver.startClient(SafariDriver.java:112)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:115)
    at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:83)
    at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:73)
    at com.brightech.mb.selenium.AbstractSeleniumBase.setUp(AbstractSeleniumBase.java:73)
    at com.brightech.mb.selenium.rules.RetryRule$1.evaluate(RetryRule.java:27)
    at com.carrotsearch.junitbenchmarks.BenchmarkStatement$BaseEvaluator.evaluateInternally(BenchmarkStatement.java:76)
    at com.carrotsearch.junitbenchmarks.BenchmarkStatement$ConcurrentEvaluator$EvaluatorCallable.call(BenchmarkStatement.java:153)
    at com.carrotsearch.junitbenchmarks.BenchmarkStatement$ConcurrentEvaluator$EvaluatorCallable.call(BenchmarkStatement.java:139)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)
----------------------------------------------------------------------------------

I already tried 

DesiredCapabilities aCap = new DesiredCapabilities();
            aCap.setCapability(SafariDriver.DATA_DIR_CAPABILITY, "/Users/" + System.getProperty("user.name")
+"/Library/Safari");
            myDriver = new SafariDriver(aCap);

to override the path incase TeamCity was messing things. 
No such luck. Any ideas?


Selenium 2.33.0
OS: Mac OS X 10.7.4
Browser Safari Version 6.0
TeamCity 6.5.6 


Reported by alfonso.vazquez@gm.mediabeacon.com on 2013-12-16 22:02:58

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Fixed. In Any case anyone else runs into this.

Teamcity hold a set of system properties for its own user  and needed to fix by using
System.getProperty(user.home);

Reported by alfonso.vazquez@gm.mediabeacon.com on 2013-12-30 18:16:41

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

What is the python equivalent of this?

DesiredCapabilities aCap = new DesiredCapabilities();
            aCap.setCapability(SafariDriver.DATA_DIR_CAPABILITY, "/Users/" + System.getProperty("user.name")
+"/Library/Safari");
            myDriver = new SafariDriver(aCap);

Reported by mirmf1 on 2014-02-14 16:57:34

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Im using Selenium 2.41, Mac_OSX = 10.8.5, Safari = 6.0.5 

Im new to mac, while launching Safari driver getting below error message

"The expected Safari data directory does not exist: /Users/null/Library/Safari"

From your comments i understand adding capabilities should fix the issue. May i know
what is "SafariDriver.DATA_DIR_CAPABILITY" ???

aCap.setCapability(SafariDriver.DATA_DIR_CAPABILITY, "/Users/" + System.getProperty("user.name")
+"/Library/Safari");

Im unable to access "DATA_DIR_CAPABILITY" method... Please let me know if im doing
something wrong.


Thanks in advance

Reported by siddarthbhatia on 2014-09-03 13:34:23

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I am too facing same issue, and I am too unable to access SafariDriver.DATA_DIR_CAPABILITY.
Please point what I am doing wrong.

Reported by sachdefine on 2015-01-19 12:12:24

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

seems the fix is not in selenium 2.44.

Reported by qqgong on 2015-02-06 08:19:58

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

When launching the hub and node, don't use 'sudo' as this would search for Safari at
the root level, but you might have installed Safari under your login user name.

If you are admin on your Mac, try simply 'java -jar selenium-standalone.x.x.x.jar -role
hub' from the account where you logged in to install latest OSX update/safari

Reported by dineshmohaninator on 2015-07-09 15:51:55

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by luke.semerau on 2015-09-17 18:16:56

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 4, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant