Uploading Image using ChromeDriver on Android - java

I'm trying to upload a image in Android using ChromeDriver.
so at first, i used sendKeys(IMG_PATH_ON_PC); to input but it wasn't worked.
console says
Failed to load resource: net::ERR_ACCESS_DENIED
and then i tried to upload it from my device.
i pushed an image via adb to /sdcard/imgtoupload.png
and used sendKeys('/sdcard/imgtoupload.png'); but it doesn't work either.
ChromeDriver says it's not an Absolute Path.
what do i need to do?

I found it.
use //mnt/sdcard instead of /sdcard

Related

unable to upload image when run my code in github actions

I need to upload an image using selenium webdriver and run it locally and on GitHub actions using java language :
I added the image in the folder in my project
get absolute path to my image
used sendKeys() to send the absolute path of my image
when running code locally works fine but when running it on GitHub Action returns an error "org.openqa.selenium.InvalidArgumentException:"
File file = new File("src/main/resources/UploadImage/MyImage.png");
imageUploadChooseFile.sendKeys(file.getAbsolutePath());
Screenshot for the error :
Screenshot for the error

Selenium ChromeDriver use custom profile folder - permission error

so I'm trying to create a custom webdriver (as in (down)load the normal driver but use custom profile settings) to get it to open any tab with a popped-out DevTools window (set to "Console").
I figured I could do that by setting up such a preference file by just interacting with my own installed Chrome version and copying my preferences to another folder, then let the Selenium WebDriver load its preferences from that folder.
But when I tried starting the WebDriver using this:
options.addArguments("--profile-directory=\"Default\"");
options.addArguments("--user-data-dir=./temp-selenium");
... it always shows an error (in german, roughly translated to):
Google Chrome can't read or write in the following directory: ./temp-selenium
Removing the second line completely just starts a Chome window with a user profile selection prompt. Setting up a file path to something like AppData doesn't work because then I get the following error:
Could not remove old devtools port file. Perhaps the given user-data-dir at "myFilePath\User Data" is still attached to a running Chrome ...
By the way, why I'm doing this: I just want to SEE the console logs while testing stuff. Can't imagine it's actually THIS difficult to get to it. My tests are way too fast to manually open the console in time and I need to find a bug that happens every 100 tries. Opening the console 100 times is just way too tedious.
Anyone have an idea?

Restoring sqlite.db file after downloading it from gmail

I need some help i am working on backup and restoring sqlite.db file , In this process i store a copy of db file in my device storage and restore it from there which is working perfectly fine. But when i send this file through any email server like gmail and download it into my storage it add timestamp to its name i handled that in code but it says file not found exception ,i guess gmail is not downloading it properly in storage or not giving access to other apps .
Whenever i rename that file just replacing any alphabet from that name than i can restore that file please help me out i am stuck here ,Thanks in advance
I have found the solution :
My problem was when a file is downloaded from gmail or any other server when we try to get its path it does not give its actual path it give path like /downloads/#2386
so when i try to open it, it shows file not found exception so to overcome this problem i have to get actual file path from that path, after getting that path and try to open it, it works perfectly fine.

How to use JavaCv's cvSaveImage in android

I have created an app using javaCv and
I'm trying to save an image in android using
cvSaveImage("/storage/sdcard0/watermarked/test.jpg", yCrCb);
cvSaveImage("/storage/extSdCard/test.jpg",yCrCb);
where yCrCb is an IplImage.
There is no exception error and the program runs smoothly but the files are not saved into the path as mentioned above.
I would like to ask what might be the possible problems ? is it the naming convention of the file name ?
If it helps, I have a java application counterpart of this app and the java version works fine when i use the line
cvSaveImage("C:\\testing123.jpg", yCrCb);
Hi I have used same thing for storing the image.
For getting the path to sdcard, I have used the Environment.getExternalStorageDirectory().toString();
append the folder name to this path where you want to store the image
try this and also make sure that you have written permission in the xml file.

How to access webcams with JMF?

I would like to access my webcam with JMF, create a snapshot, and email it. I have working email code, but every time I try:
CaptureDeviceInfo inf = CaptureDeviceManager.getDevice("vfw:Microsoft WDM Image Capture(Win32):0");
player = Manager.createRealizedPlayer(inf.getLocator());
But I get a nullpointexception error. How to fix it?
This is because your code is not detecting the webcam
you must copy the jmf.properties file to the same directory as your executable jar
you will find the jmf.properties file int the lib folder of your jmf installation.
For me it was C:\Program Files\JMF2.1.1e\lib\jmf.properties
the device name is "Microsoft WDM Image Capture", what you pass to CaptureDeviceManager.getDevice(). the "vfw://0" part is the locator.
see Owen McGovern's example: http://geoffair.net/java/java_sun1.htm. It has working player and working snapshot code.

Categories

Resources