Can we verify image dimension in a PDF by Selenium webdriver? - selenium-webdriver

I have a requirement to verify the image dimension of a PDF, which is getting downloaded and saved to a particular location. I am curious to know that, is there any way we can check the image dimension of a PDF using Selenium WebDriver? Please help.

Selenium WebDriver is for browser automation. If your requirement is to validate pdf files, contents, images in the pdfs etc, I would suggest you to use the below pdf library.
http://www.testautomationguru.com/introducing-pdfutil-to-compare-pdf-files-extract-resources/

Related

Grab and save SVG File using selenium - C# Selenium chromedriver WinForm

I am writing WhatsApp tool in C# winform using Selenium ChromeDriver.
I have handled all operations like sending the message, clicking the attachment and all from WhatsApp web using Selenium ChromeDriver.
I want to read the WhatsApp web's QR Code which is in SVG format. I want to read the SVG File and convert and save as image in local.
I could save the QR Code using snapshot, but I don't prefer using this because I have to maintain vertical scroll position to bring full QR Code on screen.
So please help me save svg file image using chromedriver
Thank you.
-Ishrar
I'm not sure of the specific commands in Selenium, but can't you just:
copy the SVG code via Javascript/a Selenium method
then create a new .svg file in Java and save this copied svg code as the contents?

Image upload functionality- xpath issues

We have a upload functionality where we can upload .csv files and I am trying to automate this using selenium webdriver.
Here is the xpaths i have used,but none of them are working.
//span[contains(text(),'click here to browse')]
//input[#type='file']
Any suggestions for this type of functionality
Below is the UI

Edge Upload File control using Selenium

I am trying to upload a file using Selenium Webdriver on the Edge browser, and yes I have downloaded EdgeDriver and installed the MSI for testing Edge. Clicking on elements on the screen from within the Edge browser works fine. The problem is the upload file control. My code is as follows:
IWebElement fileUploader2 = Browser.Driver.FindElements(By.CssSelector("input[type='file']"))[0];
fileUploader2.SendKeys(FileUtility.FileUploadsDirectory + "\\sample-account_balances.xlsx");
The code above works for Chrome and Firefox, but does not work for Edge. This is a ReactJS web app. I have tried the suggestions below that are similar to my code above and I cannot seem to upload a file using the control programmatically from Selenium Webdriver. There is no error given it just does not click on send text to the file upload control. Nothing is executed:
How to upload file using Selenium Webdriver?
File Control on Edge
DOM Upload Control Edge
Unfortunately this feature has not been added to the edge webdriver yet. I've run into the same problem and have not been able to find a suitable solution yet. One (admitedly not ideal) solution is to use AutoIt to automate the file upload for edge. There are multiple reports of this issue, but here's one of the latest reports showing that its an issue with the edge driver.

Automate Adobe PDF web forms (XFA) using selenium web driver

How to automate Adobe PDF web forms (XFA) using selenium web driver ? How to inspect elements in order to input text or click submit button in PDF forms ? These pdf forms are only supported by IE and no other browsers
Selenium Webdriver can only perform operations on DOM.
Can you right click on the form and see if view source option is coming?If not,then i don't think you can input anything on your Adobe PDF using Selenium Webdriver.
You can't automate PDF file but yes you can verify any text any content in PDF file. You can try below code if it met your requirement
Try below code:-
public void ReadPDF() throws Exception {
URL TestURL = new URL("http://www.axmag.com/download/pdfurl-guide.pdf");
BufferedInputStream TestFile = new BufferedInputStream(TestURL.openStream());
PDFParser TestPDF = new PDFParser(TestFile);
TestPDF.parse();
String TestText = new PDFTextStripper().getText(TestPDF.getPDDocument());
Assert.assertTrue(TestText.contains("Open the setting.xml, you can see it is like this"));
}
Download libraries :- https://pdfbox.apache.org/index.html
Hope it will help you :)

Aspose PDF viewer

I am using the Aspose PDF tools and have successfully got it to print the pdf which is great, but ideally I want to be able to add a wpf control to display this as well.
I would have assumed that the PdfViewer class would have something, but I can't tell.
So far I have needed to use a different control MoonPdfPanel which is annoying as I would have preferred 1 tool to do both jobs.
Does anyone know of a control I can use to hook into the aspose?
Thanks
We have developed an HTML5 PDF Editor application using Aspose.Pdf for .NET API which you can use in your application as a PDF Viewer as well. You can get the details and complete source code here. You can use the source code to edit the viewer as per your requirement.
P.S. I am working as social media developer at Aspose.
Well, if you are interesting in viewing the PDF file, you may convert the file to HTML and display it using an IFrame in your application. I have developed a sample application which performs different operations including viewing a PDF file in IFrame. Download it and try it at your end. Another option is that you can convert the PDF file to images and display in Imageviewer in your application (Code is available in the above application).
P.S. I am working as social media developer at Aspose.

Resources