I want to upload the picture so that I can access it in my project, I have used the sendKeys("path of the picture") but by using it no action is performed,
please guide me, how to use the window pop up to upload the picture or give some idea, how can I upload the picture:
WebElement Account_logo = adriver.findElement(By.xpath("//*[#id='step1']/div[1]/div/div/div/form/div[12]/div[1]/div/div/span/div[2]/div[2]"));
Account_logo.click();
Account_logo.sendKeys("C:/Users/romit/Desktop/LOGO.jpg");
When setting the file path in your Java IDE, use the proper escape character for the back-slash.
Account_logo.sendKeys("C:\\Users\\romit\\Desktop\\LOGO.jpg");
Hope it helps !
If you want to upload a file, without having 'input' element, please refer SO Post
Related
I want to get the last downloaded file name to read it from java. I am working with selenium and need to get the last downloaded file name from chrome download list or from my download directory.
You can open downloads page in the new tab. The page is using shadow-root, so you have to do a little tricks to access the elements. Please, see the answer on this page, especially the JavaScript example. It will help you get around shadow-root and access the elements you need
I am trying to write a java program that uses selenium to perform web actions. In the case of uploading a video there is a frame where the user clicks that brings up the File Explorer for Windows. I have not been able to find anything that will help me in getting the focus to the File Explorer to select a file. There is no "browse" on the page with a textbox for me to just send a filename to.
Here is what the page looks like:
I would try using Selenide because it has a pre-canned upload utility that might save you some time/effort. See the command .uploadFromClasspath in the docs. One of the project videos/pages shows a little more detail on how to do it.
I've not actually tried it, but if this works for you and you figure it out, please share.
What I have done in the past is to use the "Apache HttpUtils" class to simulate the upload action from my test. All you need is the upload URL, and the HTML page usually provides that. That might also work for you.
I have created an application in JSwing that has a button that I want to open the user manual (which is a html file) in a browser. I can successfully open the entire webpage, but I want to link to certain anchors in the document. For example I am trying to use this code:
URI uri = new URI("c:/Giggafriggin/user_manual/user_manual.html#h1_3");
Desktop.getDesktop().browse(uri);
But this causes an error, claiming the file cannot be found. But if leave off "#h1_3" it opens the page in a browser without a problem. The anchors work when i enter them into the browser manually. Any ideas?
You -could- have that linking to another html page which goes to the end uri. Unfortunately, Java is not a web browser.
Looks like this is a known issue you wouldn't run into if you were using HTTP instead of a local file.
One easy fix is simply to point to a version of the that's already online instead of on disk.
If you can't assume the content is available online, you could always spin up an embedded HTTP server like jetty inside your application and point to that instead.
I have to automate a case in which I have to download an excel file using selenium ide.I have done this in firefox by using custom profile feature which automatically download file and save it into a user defined folder. To do the same in Internet explorer, is there any thing in IE like custom profile and preferences? how do I prompt IE to automatically download a file..I am using java for automation..Kindly help..
No, you can't do it easily in IE, there's no profile to configure.
That said, you can try:
downloading the file directly using this (or any other similar WebDriver-friendly tool), if you can. That will totally cut IE out of the process.
see How to download and save a file from Internet using Java? about the same thing, just generic Java and not WebDriver.
if everything fails, you can try blindly pressing Enter after clicking the download, Robot helps with this. But you can't really specify the folder.
Is there any way to download an applet embedded in a webpage of a site www.abc.com1, to one's system?
Or is it possible to extract its code for offline use?
E.G. http://www.falstad.com/dotproduct/
For the link provided, I see the link "Zip archive of this applet.". It contains the applet jar, html page and the java source file.
You can try to inspect the page source to see the archive file it is using. In this case, it appears as if it is using http://www.falstad.com/dotproduct/dotproduct.jar. You can use this in a project, but the source will not be attached.
The applet at http://www.falstad.com/dotproduct/ can certainly be used off-line. I tested it just to make sure.
You would need to download the dotproduct.jar (referenced in the page - are you familiar with "View Source"?) to the local file-system then create an HTML (or use a copy of Paul Falstad's own HTML) to launch it.
You might try "Save page as" for the 2nd part, but I am not confident that that would also download the Jar of the applet itself.
Of course, it would be courteous to let Paul know what you are doing. You might find he will be prepared to send you a Zip of the HTML/applet.