Upload photo with codeception - codeception

I'm doing a automated test in a drupal site with codeception. In this test I need to create a news content. But I need to upload a photo to this news and I don't find any manner to do this. To make it easy to understand, in the test it will be fill the title and description field, after that it will click in the upload field and select a photo from project files to upload.
I need a manner to do this upload with the codeception.

Use attachField method - https://codeception.com/docs/modules/WebDriver#attachFile
$I->attachFile('input[#type="file"]', 'prices.xls');
Field label, XPath or CSS Path expression can be used as the first parameter,
see examples at https://codeception.com/docs/03-AcceptanceTests#Click

Related

a visual tool for upload status of file in BigCommerce

BigCommerce allows for product options that a user can upload a file to attach to an order (think a business card printer needs art files uploaded to the order)
Once a user selects all the options, and clicks add to cart, the page uploads the selected file along with the order details and takes you to the shopping cart. The time it takes for it to load depends on the weight of the files being uploaded.
Does anyone have a solution for having a visual tool for while a file is uploading, a percentage (either bar, or numbers) can be shown (or simply a "uploading images" overlay). People who are not familiar with the site think the page has frozen - they only realize when they let it upload - sometimes files can take up to 30 seconds to upload.
Im fairly proficient at CSS and HTML5 - if there are any solutions, please advise.
Thanks!
-Sebastian
In this case, you'd need to add HTML and CSS to create and style the loading bar. For the actual function of checking the upload status and displaying the progress, I'd suggest using jQuery with form plugin (uploadProgress function).
The necessary steps required to accomplish this will be a bit different in Bigcommerce than you'd see in this blog post, but it is explains it in a bit more depth with examples

Can JQuery File upload be used without AJAX?

I want to use something along the lines of JQuery file upload (i'm open minded) in a form with lots of other fields for the UI (ex. image previews, delete, file sizes .etc), but I want to submit the files along with the form as if i used a normal HTML file field.
Is this at all possible?
If you console.log() the form after submission you will get an object in return that has a bunch of information. Among that information you can find for example file information of the file you just upload.
You can check this http://jsfiddle.net/1r0Lprkj/1/ and open your console after you've submitted the form.
Then if you want to go deeper into this, then you can check out the Javascript FileReader which lets you do a bunch of cool stuff with the uploaded file. https://developer.mozilla.org/en-US/docs/Web/API/FileReader
To answer your question; Yes it is possible to achieve without AJAX.

How to add a custom image (<xh:img>) to PDF

We would like to add an image to our PDF in Orbeon. We explorered different tags and came up with tag. This worked the way we wanted but this tag keeps the PDF from building. We don't get any (visible) errors but a time-out occurs after couple of seconds.
To cross check: PDF build fine without the xh:img tag.
I was wondering what other options do we have. I thought about a PDF template but we would like to give the form author the option to choose his/hers own jpg from a web resource.
This is on 43PE.
User error yet we didn't change much after all.

What's the recommended way to add content with images and text?

What's the recommended way to add content to my rails app ? pages with cloud hosted images like amazon s3& formatted text ?
What I want is just to create a tutorial pages that are easily linked with an index page.
Is there a recommended approach rather than re-inventing the wheel ? what's the popular gems out there ?
If you need fixed content you have just to create an html in the public folder with the html that you need, and link directly from your index view to them.
In order to store the images in the cloud, just upload them and put a reference link to your page fixed content to it.
Otherwise, if you are building a dynamic page that you may upload new images and etc...
Use the paperclip gem. It is a good way to not reinvent the wheel!

Checking the contains of an embed tag using Selenium

We generate a pdf doc via a call to a web service that returns the path to the generated doc.
We use an embed html tag to display the pdf inline, i.e.
<div id="ctl00_ContentPlaceHolder2_ctl01_embedArea">
<embed wmode="transparent" src="http://www.company.com/vdir/folder/Pdfs/file.pdf" width="710" height="400"/>
I'd like to use selenium to check that the pdf is actually being displayed and if possible save the path, i.e. the src link into a variable.
Anyone know how to do this? Ideally we'd like to be able to then compare this pdf to a reference one but that's a question for another day.
As far as inspecting the pdf from selenium, you're more or less out of luck. The embed tag just drops a plugin into the page, and because a plugin isn't well represented in the DOM, Selenium can't get a very good handle on it.
However, if you're using Selenium-RC you may want to consider getting the src of the embed element, then requesting that URL directly and evaluating the resulting PDF in code. Assuming your embed element looks like this <embed id="embedded" src="http://example.com/static/pdf123.pdf" /> you can try something like this
String pdfSrc = selenium.getAttribute("embedded#src");
Then make a web request to the pdfSrc url and do (somehow) validate it's the one you want. It may be enough to just check that it's not a 404.