Uploading pdf file with cypress - automation

I need to create automatic test that as part of the flow i need to upload pdf file in my main application.
But i didnt find a way to do that...
Thanks in advance !

Uploading file works in Cypress when target "input" element is of "type="file"
cy.get("#myFile").selectFile("cypress/fixtures/dummy.pdf")
where ID of the input of type file= #myFile" and path of pdf file="cypress/fixtures/dummy.pdf"
Please refer to Cypress Docs: https://docs.cypress.io/api/commands/selectfile

Related

React-Native file viewer

Hello fellow developers,
I am looking for react native code for doc,pdf,ppt and xls viewer in mobile. I want to read these files from assets folder,local storage and also from url link.
Can someone please share the code for the above requirement.please
Thanks in advance
when I tried the code from this link: https://www.npmjs.com/package/react-native-doc-viewer
You need a semicolon before the filename (after the base64) else the object is not complete
Like
//snip
base64: "{BASE64 STRING}",
filename: "sample",
//snip

Play sound with Oboe with .obb file

Hello sorry I'm begginer.
I don't have my sound files in my assets folder but in my .obb
I'm using the RythmGame sample who is using only assets folder.
I'm trying to use DataSound but only AAssetDataSource is used in my sample for create a DataSound.
I look at Asset and NDKExtractor for the decode function, but can only be use with an AAsset from an AssetManager...
How can I play sound from an .obb with Oboe ?
Can someone help me with that problem ?
Thanks
You should be able to do this by getting the path to your expansion file and passing that through JNI to your native code, opening it as a normal file object and passing the contents to the extractor.
You're right about the NDKExtractor::decode methods - they take an AAsset *, however it should be pretty easy to update them to take the file descriptor from your open file instead.

Selenium 2.0 - File Upload not working

I am unable to upload a file using selenium. I employ the below code:
Browser.FindElement(By.XPath(XPath)).SendKeys(path);
However, all that happens is that the file browse form comes up. The file does not get selected.
Does anyone know what I need to do to get this working, or a workaround? Many Thanks.
Refer to(saucelabs.com/resources/selenium-file-upload)
WebElement upload = driver.findElement(By.id("myfile"));
upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");
driver.findElement(By.id("submit")).click();
driver.findElement(By.tagName("img"));
Also make sure you have given the path correctly. For example if the file is in d:\abc\pqr.txt, then path needs to be given as
"d:\\abc\\pqr.txt"
Mark this as an answer if this answers your question.
If not, please post your query!
Regards,
Sakshi

Render HTML or GSP as a PDF and save it on server

I have an html template which I need to render as a .PDF and then save that pdf file on server. I'm using "rendering" plugin of grails. I'm able to render file as PDF but I don't understand how to save it on server location and not on user's system. Can anybody please help me ?
The pdfRenderingService provided by the plugin allows you to call render and get back an OutputStream. Using that output stream you can write that to a file on your server. The documentation explains the basics of using the service.
Your code may look something like this:
new File("report.pdf").withOutputStream { outputStream ->
outputStream << pdfRenderingService.render(template: '/report/report', model: [serial: 12345])
}
Well, actually I changed my plugin. Got Wkhtmltopdf plugin of grails more helpful. you can find it here --
https://github.com/quorak/grails-wkhtmltopdf
Also instructions regarding using this plugin you can find on the same link or here --
[https://github.com/quorak/grails-wkhtmltopdf]
Using this you can get "bytes" which you can write to file system.

Capybara open an html file in my computer

I have an html file in my computer and I want to open that file using Capybara to test it. Could you help me to solve this problem?
P/S: That html file is created automatically in my app. I do appreciate any idea helping me to solve this problem. Thanks :)
UPDATE:
Based on the capybara source code here, I found that I should use Capybara.current_session.driver.visit instead of page.visit. The problem is solved
I can confirm that the update to the question works (assuming the file is in the current directory):
filename = 'foo.html'
Capybara.current_session.driver.visit filename
If your file is located at /path/to/folder/file.html
Set Capybara.app to a folder containing this file:
Capybara.app = Rack::File.new('/path/to/folder')
and then
visit 'file.html'
should work for you
See also this gist for example
With simple relative file path I got errors:
Failure/Error: visit 'foo.html'
Selenium::WebDriver::Error::InvalidArgumentError:
invalid argument
I didn't want to switch Capybara.app to Rack::File and back, so I've tried this way and it works:
visit "file://#{__dir__}/foo.html"