path is not absolute: src/test/resources/testData/twt_Pic.jpg
getting this exception while uploading the file using selenium.
Instead of uploading the file using the native os file explorer, sending the keys to the path file.
The same path used to work during the older version, not sure which version was it.
Error Log in Chrome:
org.openqa.selenium.WebDriverException: unknown error: path is not absolute: src/test/resources/testData/twt_Pic.jpg
(Session info: chrome=66.0.3359.181)
(Driver info: chromedriver=2.39.562713 (dd642283e958a93ebf6891600db055f1f1b4f3b2),platform=Mac OS X 10.13.4 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'nagarjunaMBP.local', ip: 'fe80:0:0:0:c2e:b816:67ae:922b%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.4', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.39.562713 (dd642283e958a9..., userDataDir: /var/folders/g4/dylg4g7s7wb...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 66.0.3359.181, webStorageEnabled: true}
Session ID: bdf391bf16ddbda6c9f73d559404bae7
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:276)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:51)
at com.sun.proxy.$Proxy17.sendKeys(Unknown Source)
at actions.PublishBroadcast.MediaLibAction.uploadImage(MediaLibAction.java:43)
at stepDefinitions.Publish.SDMediaLibrary.Upload_an_Image(SDMediaLibrary.java:43)
at ✽.When Upload an Image(features/publish/mediaLibrary/MediaLibrary.feature:11)
Error Log for Firefox:
org.openqa.selenium.InvalidArgumentException: File not found: src/test/resources/testData/twt_Pic.jpg
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'nagarjunaMBP.local', ip: 'fe80:0:0:0:c2e:b816:67ae:922b%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.4', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 60.0.1, javascriptEnabled: true, moz:accessibilityChecks: false, moz:headless: false, moz:processID: 53177, moz:profile: /var/folders/g4/dylg4g7s7wb..., moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: MAC, platformName: MAC, platformVersion: 17.5.0, rotatable: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}}
Session ID: 7c932de3-ea6a-a143-a7b4-bf7dfa3e2660
Project Structure:
- Project/src/main/java — Contains actions, UI element repository, Step Defenitions. From where the file is being called
- Project/src/test/java — Contains only runner class
- Project/src/test/resources/customLib — Contains drivers
- Project/src/test/resources/features — Contains feature files
- Project/src/test/resources/testData — Contains the test data including the file which i’m trying to call here.
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
Closed
evilaliv3 opened this issue
May 18, 2015
· 10 comments
Comments
While testing protractor integrated in GlobaLeaks with saucelabes and implementing an end to end test for a file uploader i’m getting the following error:
Failed: unknown error: path is not absolute: /home/travis/build/globaleaks/GlobaLeaks/client/tests/glclient/test-globaleaks-process.js
the error seems sketchy ’cause as you can notice the path is an absolute path.
can anybody understand what is probably happening?
the test is runned without issues on Firefox while it is failing on Chrome;
this is the failing build: https://travis-ci.org/globaleaks/GlobaLeaks/jobs/62939365
the code i’m using is:
element(by.xpath("//input[@type='file']")).sendKeys(__filename);
where __filename is the global variabe that would contain always an absolute path pointing to the current file.
@juliemr do you have any hint on this?
The error is coming from Chromedriver — you can search for «path is not absolute» in the logs at https://saucelabs.com/jobs/c7411d5340c94320a29f61cd2f5d76e9
I think this is because your Chrome browser is on a windows computer, so Chromedriver is running on windows. This means that it’s expecting a drive name to test if the path is absolute, so /home/travis/...
doesn’t qualify as an absolute path on windows.
There’s been a lot of confusion about file uploading lately. Protractor has deferred to WebDriver’s implementation here, but it’s clear that we need to do a better job with helpers and docs. I’m going to consolidate under one bug.
Copy link
Contributor
Author
thank you @juliemr
so probably this documentation also should be updated.
given what is stated there i was thinking that the path should not change depending on the filesystem and that automatically somewhere there would be some pice of code handling it
When running against a remote Selenium server, a webdriver.FileDetector may be used to transparently copy files to the remote machine before attempting to upload them in the browse
let me say that what you suggest about windoes is not correct; this behaviour happend also on linux/mac: https://saucelabs.com/u/globaleaks
as we (protractor user) would be interested simply in using this capability for testing it would be great to find an alternative way to load a file testing a file uploader button without requiring a file to be present on the filesystem. e.g. something like usin a Blob or a data:// uri. do you know if something like this is possible?
Copy link
Contributor
Author
gotcha! you are right, i didn’t noticed it.
so to solve the issue we should find out a proper way to document in order to write a piece of code usable for all the OS without failures.
Yup. I’m closing this, let’s follow up in #2153
same problem to me.
Then, how to solve it ?
I still have this problem. Is there a better fix/documentation for uploading files yet?
Still have the problem with selenium 3.0.1 and protractor 4.0.14. Any chance to have this feature working ?
Also hitting this as of late, but am running 4.0.14 as well (@jmcollin78). The chain of linked and referenced threads is not exactly straightforward on the case of linux->windows tests.
Is the best option here if we’re running a windows selenium node to drop the file on that machine and refer to the path of the file with a windows path? I’ve been autogenerating them in the suite (unique new pem/cert), so that’s a little less than ideal. Otherwise I guess setting up a linux hub/node is the only alternative (I want to avoid running an instance on the CI machine doing the deploy/test run)?
Path is not absolute: src/test/resources/testData/twt_Pic.jpg получает это исключение при загрузке файла с использованием селена.
Вместо того, чтобы загружать файл с помощью собственного проводника файлов ОС, отправляйте ключи в файл пути.
Тот же путь использовался для работы в более старой версии, не знаю, какая это была версия.
Ошибка входа в Chrome:
org.openqa.selenium.WebDriverException: unknown error: path is not absolute: src/test/resources/testData/twt_Pic.jpg
(Session info: chrome=66.0.3359.181)
(Driver info: chromedriver=2.39.562713 (dd642283e958a93ebf6891600db055f1f1b4f3b2),platform=Mac OS X 10.13.4 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'nagarjunaMBP.local', ip: 'fe80:0:0:0:c2e:b816:67ae:922b%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.4', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.39.562713 (dd642283e958a9..., userDataDir: /var/folders/g4/dylg4g7s7wb...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 66.0.3359.181, webStorageEnabled: true}
Session ID: bdf391bf16ddbda6c9f73d559404bae7
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:276)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:51)
at com.sun.proxy.$Proxy17.sendKeys(Unknown Source)
at actions.PublishBroadcast.MediaLibAction.uploadImage(MediaLibAction.java:43)
at stepDefinitions.Publish.SDMediaLibrary.Upload_an_Image(SDMediaLibrary.java:43)
at ✽.When Upload an Image(features/publish/mediaLibrary/MediaLibrary.feature:11)
Журнал ошибок Firefox:
org.openqa.selenium.InvalidArgumentException: File not found: src/test/resources/testData/twt_Pic.jpg
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'nagarjunaMBP.local', ip: 'fe80:0:0:0:c2e:b816:67ae:922b%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.4', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 60.0.1, javascriptEnabled: true, moz:accessibilityChecks: false, moz:headless: false, moz:processID: 53177, moz:profile: /var/folders/g4/dylg4g7s7wb..., moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: MAC, platformName: MAC, platformVersion: 17.5.0, rotatable: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}}
Session ID: 7c932de3-ea6a-a143-a7b4-bf7dfa3e2660
Структура проекта:
- Project / src / main / java — содержит действия, репозиторий элементов пользовательского интерфейса, определения шагов. Откуда вызывается файл
- Project / src / test / java — содержит только класс бегуна
- Project / src / test / resources / customLib — содержит драйверы
- Project / src / test / resources / features — содержит файлы функций.
- Project / src / test / resources / testData — содержит тестовые данные, включая файл, который я пытаюсь вызвать здесь.
path is not absolute: src/test/resources/testData/twt_Pic.jpg
получение этого исключения при загрузке файла с использованием селена.
Вместо загрузки файла с помощью собственного обозревателя файлов OS, отправка ключей в файл пути.
Тот же путь, который использовался во время старой версии, не уверен, какая это была версия.
Журнал ошибок в Chrome:
org.openqa.selenium.WebDriverException: unknown error: path is not absolute: src/test/resources/testData/twt_Pic.jpg
(Session info: chrome=66.0.3359.181)
(Driver info: chromedriver=2.39.562713 (dd642283e958a93ebf6891600db055f1f1b4f3b2),platform=Mac OS X 10.13.4 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'nagarjunaMBP.local', ip: 'fe80:0:0:0:c2e:b816:67ae:922b%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.4', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.39.562713 (dd642283e958a9..., userDataDir: /var/folders/g4/dylg4g7s7wb...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 66.0.3359.181, webStorageEnabled: true}
Session ID: bdf391bf16ddbda6c9f73d559404bae7
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:276)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:51)
at com.sun.proxy.$Proxy17.sendKeys(Unknown Source)
at actions.PublishBroadcast.MediaLibAction.uploadImage(MediaLibAction.java:43)
at stepDefinitions.Publish.SDMediaLibrary.Upload_an_Image(SDMediaLibrary.java:43)
at ✽.When Upload an Image(features/publish/mediaLibrary/MediaLibrary.feature:11)
Журнал ошибок для Firefox:
org.openqa.selenium.InvalidArgumentException: File not found: src/test/resources/testData/twt_Pic.jpg
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'nagarjunaMBP.local', ip: 'fe80:0:0:0:c2e:b816:67ae:922b%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.4', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 60.0.1, javascriptEnabled: true, moz:accessibilityChecks: false, moz:headless: false, moz:processID: 53177, moz:profile: /var/folders/g4/dylg4g7s7wb..., moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: MAC, platformName: MAC, platformVersion: 17.5.0, rotatable: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}}
Session ID: 7c932de3-ea6a-a143-a7b4-bf7dfa3e2660
Структура проекта:
- Project / src / main / java — содержит действия, хранилище элементов пользовательского интерфейса, пошаговые определения. Откуда файл вызывается
- Project / src / test / java — содержит только класс бегуна
- Project / src / test / resources / customLib — содержит драйверы
- Project / src / test / resources / features — содержит файлы компонентов
- Project / src / test / resources / testData — содержит тестовые данные, включая файл, который я пытаюсь вызвать здесь.
I am using Linux. I have access to the root for my user.
root@marais:~# pwd
/root
In this directory I have the following:
root@marais:~# ls
example.log log_watcher.service log_watcher.sh
log_watcher.service
[Install]
WantedBy=multi-user.target
[Unit]
Description=Log Watcher Service
[Service]
ExecStart=log_watcher.sh
log_watcher.sh
# File to output to
ErrorLogFile="./error.log"
# File to read from
ExampleLogFile="./example.log"
if [ ! -e "$ErrorLogFile" ]; then # check if file exists
echo "Creating error file $ErrorLogFile"
touch $ErrorLogFile
fi
echo "copying error messages from $ExampleLogFile to $ErrorLogFile"
# copy from one file to the other
### Challenge 1 ###
# grep ERROR $ExampleLogFile > $ErrorLogFile
### Challenge 2 ###
# tail -f $ExampleLogFile | grep --line-buffered ERROR | tee $ErrorLogFile
while :; do grep ERROR $ExampleLogFile > $ErrorLogFile; sleep 2; done
echo "done"
I run the following:
systemctl enable log_watcher
This seemed to work successfully, because I had messaged of it setting up symlinks.
Now when I try start the service:
systemctl start log_watcher
Nothing seems to happen, i.e. the log_watcher.sh
is not called.
So when I get the status:
systemctl status log_watcher
It says that the log_watcher.sh
is not called with an absolute path.
root@marais:~# systemctl status log_watcher
● log_watcher.service - Log Watcher Service
Loaded: error (Reason: Invalid argument)
Active: failed (Result: exit-code) since Fri 2019-10-18 10:49:32 CEST; 9min ago
Main PID: 2850 (code=exited, status=203/EXEC)
Oct 18 10:49:32 marais systemd[1]: Started Log Watcher Service.
Oct 18 10:49:32 marais systemd[1]: log_watcher.service: Main process exited, code=exited, status=203/EXEC
Oct 18 10:49:32 marais systemd[1]: log_watcher.service: Unit entered failed state.
Oct 18 10:49:32 marais systemd[1]: log_watcher.service: Failed with result 'exit-code'.
Oct 18 10:50:12 marais systemd[1]: [/root/log_watcher.service:8] Executable path is not absolute, ignoring: log_watcher.sh
Oct 18 10:50:12 marais systemd[1]: log_watcher.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Warning: log_watcher.service changed on disk. Run 'systemctl daemon-reload' to reload units.
When I run:
root@marais:~# readlink -f log_watcher.sh
/root/log_watcher.sh
It shows that my absolute path is /root/
, and this is the path I have defined in log_watcher.service
:
ExecStart=/root/log_watcher.sh
Question
Please can you advise how I can get this service to start and execute the log_watcher.sh
.
Thank you