Html2canvas screenshot is very different from the original picture. How to solve it
This is the address of my code https://github.com/cxm1308377432/html2canvas-screenshot
The above is the interface written with vue-grid-layout, you can modify the layout at will, and the below is the screenshot, but the two are very different
function download() {
var this1 = this;
setTimeout(function() {
html2canvas(this1.$refs.mine, { backgroundColor: null }).then(canvas =>
{
let dataURL = canvas.toDataURL("image/png");
this1.downImg = dataURL; console.log(dataURL);
});
}, 1000);
}
You better have a screenshot to show how different it is. But from my experience when I'm working with that library (html2canvas), the canvas can't render from difference origin. That's CORS problem. Unlucky, I haven't found any solution for this situation.
I read your source but can't found any image url so please update your answer with screenshot.
When I perform
cy.get('#fsp-name').clear().type('random text');
If the text already has value lets say 'assd asd adsdsd' and I perform above command I get something similar to 'random textassd'
I also tried using
cy.get('#fsp-name').clear().should('have.value', '').type('random text');
It works some time and in other times it complains it does not equal to ' '.
And I am trying to do this in a each loop like below
const data = [
{selector:'#name', newValue: 'John'},
{selector:'#phone', newValue: '1234567'}
];
cy.wrap(data).each(field => {
cy.get(field.selector).clear().should('have.value', '').type(field.newValue);
cy.contains('Save').click();
cy.visit('/abc/sdd');
cy.get(field.selector).invoke('val').should('equal', field.newValue);
});
Tried the solutions provided above, but all did not help.
I've ended up using this:
cy.get('#my-input-element').focus().clear();
If that doesn't work, the not so happy workaround is:
cy.get('#my-input-element').invoke('val', '');
When .type somehow did not finish the given string (rare cases):
cy.get('#my-input-element').invoke('val', 'Some text here');
I had a similar problem and It was related to focused and click related. I can suggest trying the following two option. I DON'T know it is right or wrong.
cy.get('#fsp-name').click().clear().type('random text');
OR
cy.get('#fsp-name').click().focused().clear().type('random text');
I was talking to the developer and according to him we are using MaterialUI and have some default component using focused and click event differently. After having both options resolved my problem
.clear() is an alias of .type('{selectall}{backspace}') however depending upon the input field set up this would not work in all cases.
I solved this by using .type('{selectall}{backspace}{selectall}{backspace}') instead of the .clear()
I'm using Cypress version 3.8.3 and I noticed that I have to invoke clear() sometimes two times in a row:
cy.get('#fsp-name').clear();
cy.get('#fsp-name').clear();
Seems like the cypress test runner is getting ahead of app initialization and some helpful article links below
https://www.cypress.io/blog/2018/02/05/when-can-the-test-start/
https://www.cypress.io/blog/2019/01/22/when-can-the-test-click/
As of now adding wait before clearing makes the test pass. Let me know if anyone has better solutions
I've had the same problem using Mui React with Cypress and when I called clear an ";" was added.
I've applied the same #Steven Vachon solution calling clear() function of cypress first.
Here my solution:
const clearInputElement = (input) => {
const input2Search = input;
cy.get(input2Search).clear();
cy.get(input2Search).then(($elm) => {
const event = new Event(input2Search, { bubbles: true, cancelable: true });
const input = $elm.get(0); // `as HTMLInputElement` for TypeScript
input.value = "";
input.dispatchEvent(event);
});
};
I ended up having to do clear manually via the DOM:
cy.get('input').then($elm => {
const event = new Event('input', { bubbles: true, cancelable: true });
const input = $elm.get(0); // `as HTMLInputElement` for TypeScript
input.value = '';
input.dispatchEvent(event);
});
I, too, faced a similar issue while using with react-ace editor. I wind up with
function typeContentOnSelectingExistingContent(elementId, content) {
return cy.get(`#${elementId}`).type(`{selectAll}{selectAll}${content}`)
}
Try this, it worked for me:
cy.get('#fsp-name').clear({ force: true }).then(() => {
cy.wait(3000)
cy.get('#fsp-name').invoke('val', '').type(`${valueToBeTyped}{enter}`)
})
Official docs states that:
It is unsafe to chain further commands that rely on the subject after .clear().
That's probably why the code in the original question didn't work, it was chaining clear and type commands:
cy.get('#fsp-name').clear().type('random text');
So, a simple alternative would be something like:
cy.get('#fsp-name').clear()
cy.get('#fsp-name').type('some text')
More about the clear command:
https://docs.cypress.io/api/commands/clear
I 'm using https://rowanwins.github.io/vue-dropzone/docs/dist Vue2-Dropzone to work on uploading file.
Everything works fine except calculation of total-upload-progress value goes to 100% and then start from 0% on every file uploads.
I have tried to fix it with
this.$refs.myVueDropzone.updateTotalUploadProgress() adding on file
added event
. But does not work as expected. Any solution would be highly appreciated.
An old question, but facing the same issue I was forced to find a solution and here it is for everyone interested. I apologize for the long property names :-)
I'm listening to the following 2 events of the vue2-dropzone: vdropzone-upload-progress and vdropzone-file-added
<div v-html="'Progress: '+ uploadProgress"></div>
<dropzone id="upload_dropzone" ref="upload_dropzone" :options="dropzoneOptions"
#vdropzone-success="dropzoneOnSuccess"
#vdropzone-upload-progress="dropzoneUploadProgress"
#vdropzone-file-added="dropzoneFileAdded"></dropzone>
I have 3 additional properties in my data object:
data: ()=>{
....
dropzoneTotalFilesize:0,
dropzoneUploadedFilesize:0,
dropzoneCurrentUpload:0
}
},
I got one computed property:
computed:{
uploadProgress(){
return Math.round((this.dropzoneUploadedFilesize + this.dropzoneCurrentUpload) / this.dropzoneTotalFilesize * 100);
}
},
And then my event listeners, that are called in my template above
methods:{
dropzoneFileAdded(file){
this.dropzoneTotalFilesize += file.size;
},
dropzoneUploadProgress(file, totalBytes, totalBytesSent){
this.dropzoneCurrentUpload = totalBytesSent; // write totalBytes to dropzoneCurrentUpload
if(file.size <= totalBytesSent){
this.dropzoneCurrentUpload = 0; // reset current upload bytes counter
this.dropzoneUploadedFilesize += totalBytesSent; // add finished file to total upload
},
.........
},
Maybe it's possible to accomplish the same with abit less code, but this def works for single file upload as well as for multiple file upload.
I hope I could help someone with this, and help to keep VueJS competetive
I can access current .html() value of a span contained in a magnificPopup.
But I can not set this value.
This is what I mean:
parseAjax: function(mfpResponse) {
// This works perfectly
var mycontent = $(mfpResponse.data).find('#textreported').html();
// But this does not work
$(mfpResponse.data).find('#textreported').html('Text to be assigned');
}
Does anyone know what I'm doing wrong?
Thanks in advance.
I'll answer myself. This is the right way to do it:
parseAjax: function (mfpResponse) {
str = jQuery.parseHTML(mfpResponse.data)
$(str).find('#textreported').html('Text to be assigned');
mfpResponse.data = $(str)
}
It may be useful to someone.
I'm trying to add a border bottom red style to a table when the column value changes.
As shown in the picture, I want to add a bottom border when FamilyID changes it's value.
Any help is greatly appreciated and thank you in advance!
I actually just went about using a SQL workaround using the LAG command.
Used that as a flag to indicate when value has changed and set the CSS command for the event. Thanks #Piyush for the suggestion to use a flag!
I have implemented same thing on classic report of employee ,
you can check url https://apex.oracle.com/pls/apex/f?p=26095 with
userid: AMOL.PATIL#VYOMLABS.COM
pass : Unicorn#123
Code in execute JavaScript page load section:
var previous=null;
var flag;
$("td[headers=DEPTNO]").each(function() {
if(previous==null){
previous=$(this).text();
flag='true';
}
if($(this).text()==null ||$(this).closest('tr').next().find('[headers="DEPTNO"]').text()==null) {
}
else
{
if($(this).text()!=$(this).closest('tr').next().find('[headers="DEPTNO"]').text()) {
previous=$(this).text();
if(flag=='false')
flag='true';
else
{
flag='false';
}
}
if(previous==$(this).text()&& flag=='false') {
flag='true';
$(this).closest('tr').after('<tr><td></td><td></td><td></td></tr>');
$(this).closest('tr').next().addClass("myclass");
}
}
});
code for inline css section of page:
table.uReportStandard > tbody tr.myclass > td
{
background-color:red !important;
}
Output :
Similarly you can also implement same thing by just changing headers.In your case it may be FAMILYID which will replace DEPTNO here.
Please try this code ...