i want to send the sequence of key strokes Ctrl + Alt + p
i tried that but it doesn't work : .keys(['U+E009','U+E00A', 'p'])
module.exports = {
'Test' : function (browser) {
browser
.url('http://localhost:3000')
.waitForElementVisible('body', 1000)
.keys(['U+E009','U+E00A', 'p'])
(...)
.end();
}
};
someone have an idea ?
thanks
Replace this code: .keys(['U+E009','U+E00A', 'p'])
with this: .keys(["\uE009", "\uE00A", "P"])
and see if you are able to resolve the issue. For me, issue is resolved after doing this change.
Related
I'd like to create a simple Firefox extension to write a simple message to the Javascript console when a push notification is received from any site. I see there is a notification show event that seems like it should work although I can't seem to find an example of it in use. Is this possible?
I'm not sure that that API would handle your use case because the event is not global. It is placed on the object e.g.
var notify = new Notification("Hi there!").addEventListener('show', e => console.log("We showed it! ", e));
I can't think of a better solution if you want to watch for global events than what is mentioned in https://stackoverflow.com/a/36868084/4875295 -- Monkey Patching!
Copying the code from that answer for posterity:
function setNotificationCallback(callback) {
const OldNotify = window.Notification;
const newNotify = (title, opt) => {
callback(title, opt);
return new OldNotify(title, opt);
};
newNotify.requestPermission = OldNotify.requestPermission.bind(OldNotify);
Object.defineProperty(newNotify, 'permission', {
get: () => {
return OldNotify.permission;
}
});
window.Notification = newNotify;
}
How do I get my bot to send a random picture/meme in discord. I'm using discord.js and this is as far as I got.
if (msg.content === '-meme');
var randommeme = ({files:["https://cdn.discordapp.com/attachments/757397429107556422/757524795452686426/GBoat_Watermark.png"]} , {files:["https://cdn.discordapp.com/attachments/815040456244985947/816225078969892864/A_good_fluffy_goat.png"]});
var fact = Math.floor(Math.random() * randommeme.length);
msg.channel.send('goat meme', randommeme[fact]);
});
This should send a random picture but when I run the command it only says "goat meme". I tried this code before and it worked.
client.on('message', msg => {
if (msg.content === '+meme') {
msg.channel.send("This is a good fluffy goat", {files: ["https://cdn.discordapp.com/attachments/757397429107556422/816234172737126430/A_good_fluffy_goat.png","https://cdn.discordapp.com/attachments/757397429107556422/757524795452686426/GBoat_Watermark.png"]});
}
});
I really don't know what Im doing wrong here?
First create an array of links, and then use the random function to get a random link from the array.
const meme = ['link_1','link_2','link_3','link_4'];
const index = Math.floor(Math.random() * meme.length);
message.channel.send('Goat meme',{files:[meme[index]]});
where link_1, link_2 etc. are attachment file URL.
There's a typo in line two, the right code should be this:
var randommeme = ({files:["https://cdn.discordapp.com/attachments/757397429107556422/757524795452686426/GBoat_Watermark.png", "https://cdn.discordapp.com/attachments/815040456244985947/816225078969892864/A_good_fluffy_goat.png"]});
When I upload a file with Krajees Bootstrap Fileinput, I perform a server side validation of the file. When something goes wrong, I output a JSON-Object simply with {error:'Something went wrong'}. The Plugin displays the error perfectly.
But then: When I press again "upload" just after that, the $_FILES array in the called submit PHP script is empty. This means, the plugin does not send the file again even if it has notified that an error has occurred.
Why would the plugin only upload the file once even if it detects that there was an error? Are there any methods that can "reset" the "uploaded state" of the file? (I'm only uploading one file).
I already checked the file events but none of them brought me to the desired result, instead they kind of destroyed the whole upload form with certain buttons being suddenly disabled and so on.
I finally found out the exact point, where the problem could be solved:
On line 1705 in the function updateUploadLog, the function self.updateStack is called. This call simply clears the file stack and causes a later process to empty the form input. Simply commenting out this line does the trick, but only if you reload after success, because somehow fnSuccess is also called when an error is found.
#Angad thank you very much for your solution triggering input, thanks to that I found a place to start the search again ;)
I see that the Github Issue says this isn't currently supported, but it seems relatively uncomplicated to fork this project and bend it to your needs. All the fnError ='s you'll find in a Cmd + F search inside fileinput.js are where you need to look.
Take for instance here: https://github.com/kartik-v/bootstrap-fileinput/blob/d5ed3ee989edbd5d67b8cf4bdadc9f3c18609965/js/fileinput.js#L1897
This is for the batch file-upload that currently looks like this:
fnError = function (jqXHR, textStatus, errorThrown) {
var outData = self._getOutData(jqXHR), errMsg = self._parseError(jqXHR, errorThrown);
self._showUploadError(errMsg, outData, 'filebatchuploaderror');
self.uploadFileCount = total - 1;
if (!self.showPreview) {
return;
}
self._getThumbs().each(function () {
var $thumb = $(this), key = $thumb.attr('data-fileindex');
$thumb.removeClass('file-uploading');
if (self.filestack[key] !== undefined) {
self._setPreviewError($thumb);
}
});
self._getThumbs().removeClass('file-uploading');
self._getThumbs(' .kv-file-upload').removeAttr('disabled');
self._getThumbs(' .kv-file-delete').removeAttr('disabled');
};
I'd try modifying this to:
fnError = function (jqXHR, textStatus, errorThrown) {
if (!myError.equals(textStatus)) { // A service-like impl. injection would be sexier
var outData = self._getOutData(jqXHR), errMsg = self._parseError(jqXHR, errorThrown);
self._showUploadError(errMsg, outData, 'filebatchuploaderror');
self.uploadFileCount = total - 1;
if (!self.showPreview) {
return;
}
self._getThumbs().each(function () {
var $thumb = $(this), key = $thumb.attr('data-fileindex');
$thumb.removeClass('file-uploading');
if (self.filestack[key] !== undefined) {
self._setPreviewError($thumb);
}
});
self._getThumbs().removeClass('file-uploading');
self._getThumbs(' .kv-file-upload').removeAttr('disabled');
self._getThumbs(' .kv-file-delete').removeAttr('disabled');
} else {
self._ajaxSubmit(fnBefore, fnSuccess, fnComplete, function() {
// TODO: Second time failure - handle recursively or differently? :-)
);
}
};
Hope this helps!
I have a problem with Parse in Visual studio cordova. I am testing my app via Ripple and as soon as I want to register user, it tells me, that I must provide some authentication, but when I provide my crediental to Ripple, it just asks me one more time. I have absolutely no idea what password it needs from me, but I figured out, that it does in this line of code
user.signUp(null, {
success: function (user) {
window.location.href = "mainPage.html";
},
error: function (user, error) {
// Show the error message somewhere and let the user try again.
//alert("Error: " + error.code + " " + error.message);
window.location.href = "badLogin.html";
}
});
I am sure, that I typed parse initialisation properly, the appid and the js id.
You can turn off the local proxy from the options/settings on the right-side menu on the Ripple page.
I found out, Ripple had set up a local proxy and that was the catch
What I'm trying to implement is giving the users the ability to export the grid data to an excel file and download it, with the help of a file save dialog.
Here's how I have coded it right now -
In Javascript -
$.post("/irn/Identifier/Download", { "columnValues": columnValues });
In the Identifier controllers Download action -
public FileResult Download(string columnValues)
{
DTData headlineRows = (DTData)Newtonsoft.Json.JsonConvert.DeserializeObject(columnValues, typeof(DTData));
var e = new Services.DownloadToExcel();
return File(e.WriteData(headlineRows), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "testfile.xlsx");
}
In the DownloadToExcel class, inside the WriteData function I have -
//Here, I'm using the EPPlus library to write the column data to an excel file and then i'm returning the data as a byte array -
//Some code that writes the data
return packages.GetAsByteArray();
When I run this code, I expect to see a File Save Dialog in the browser, but nothing happens. There aren't any errors on the C# or JavaScript side. Can anyone tell me what i could be doing wrong?
bit late but I was having a similar issue. To solve it I used JSON.stringify(columnValues) on the client to convert my data into a json string before sending it to the controller.
Then instead of using
$.post("/irn/Identifier/Download", { "columnValues": columnValues });
try
var columnValuesString = JSON.stringify(columnvalues);
window.location = '/irn/Identifier/Download?columnvalues=" + columnValuesString';
Changing the $.post() to a window.location makes it work.
Then you can deserialize the json string in the controller and your Open/Save dialog should appear after hitting your link.
I hope this helps someone else. Let me know and I can post my code if needed.
Thanks.
If you're testing the site in Internet Explorer, try the following:
Open Internet Options -> Advanced. Click Reset. You can also choose to Restore Advanced Settings.
Open Internet Options -> Security. If zones have been changed at all, click "Reset all zones to default level".
Changes to these settings may affect whether or not Internet Explorer accepts file downloads.
More information here: http://answers.microsoft.com/en-us/ie/forum/ie8-windows_other/ie-8-will-not-let-me-download-any-files-music-pdf/bc59ba24-866b-4dbf-93f2-85ebb9912c2c
You should use IFrame to help downlaoding the file.
function postToIframe( url,data) {
var target = "downloadIFrame";
$('<iframe name="' + target + '" style="display:none"/>').appendTo('body');
$('body').append('<form action="' + url + '" method="post" target="' + target + '" id="postToIframe"></form>');
$.each(data, function (n, v) {
$('#postToIframe').append('<textarea name="' + n + '">' + v + '</textarea>');
});
$('#postToIframe').submit().remove();
}
I solved this but forgot to update here -
This worked -
Inside my class -
private const string MimeType = "application/vnd.openxmlformats-
officedocument.spreadsheetml.sheet";
private ExcelPackage package = new ExcelPackage();
private FileContentResult excelFile;
Write data using EPPlus
...
...
...
excelFile = File(package.GetAsByteArray(), MimeType, FileName);
return excelFile;