Anyone know how to use CertificateWarningHandler in WatiN?
I've got as far as...
IE ie = new IE("https://mysite.aspx");
CertificateWarningHandler cwh = new CertificateWarningHandler(CertificateWarningHandler.ButtonsEnum.Yes);
cwh.HandleDialog(new Window(ie.hWnd));
... which does precisely nothing.
On a more general note, how on earth do you people manage to use this tool? The documentation is nearly useless, and there doesn't seem to be any decent resource online. I must be missing something because it's taken me about half an hour to write 3 lines of code that don't even work.
I'm using something similar to what Saar is using and it works fine (my tests are cross-browser).
//Override security warning in browser
{
if (Browser.Link(Find.ById("overridelink")).Exists)
{
Browser.Link(Find.ById("overridelink")).Click();
Browser.WaitForComplete();
}
else
{
Browser.WaitForComplete();
} //end else
}
I'm not a developer, and I've found that there's plenty of information out there on WatiN and others post code samples and the like that are really helpful. Google is one of my best friends when it comes to finding WatiN help. You'll get the hang of it.
have you tried following already?
ie.DialogWatcher.Add(cwh);
or just
ie.DialogWatcher.Add(new CertificateWarningHandler());
Update: After comment.
Actually this works for me.
further may be following will help
Browser browser = ie;
if (browser.Links.Exists("overridelink"))
{
browser.Link("overridelink").Click();
}
Related
I'm currently developping a multi languages application using the tap-i18n package. I wonder how I can translate errors.
I can grab the code and then display a custom message that I would have written to the translation file before.
But I saw on this post there is a better way of doing this with another i18n package.
Does anyone know if there is way of doing something like with tap-i18n ?
EDIT : For now I'm doing something like this :
Meteor.call('createNewUser', newUser, function (error, ret)
{
if (!error)
displayError(TAPi18n.__('success'), TAPi18n.__('new_user_success'), TAPi18n.__('ok'), "btn-success btn-lg", "success-popup");
else
{
switch (error.error)
{
case 403:
displayError(TAPi18n.__('danger'), TAPi18n.__('new_user_already_exist'), TAPi18n.__('ok'), "btn-danger btn-lg", "danger-popup");
break;
default:
displayError(TAPi18n.__('danger'), TAPi18n.__('new_user_error'), TAPi18n.__('ok'), "btn-danger btn-lg", "danger-popup");
break;
}
}
});
My answer might be a bit off-topic, but do you mean application errors? If so, you shouldn't really return that to the users, as this could constitute a security flaw, giving them too much information.
From OWASP: https://www.owasp.org/index.php/Error_Handling
Thus, you might want to handle the errors, and give the users exactly what you want them to know.
Just include the error messages in your translation, and proceed as with normal strings to translate.
I hope this is of some help :).
EDIT:
I understand now what you mean. As far as I know, there's no such option, as there is with just-i18n. As a suggestion for unbloating the code a bit, you could use a helper function such as:
function t(keyToTranslate){
return TAPi18n.__(keyToTranslate)
}
And in the code:
displayError(t('danger'), t('new_user_already_exist'), t('ok'), "btn-danger btn-lg", "danger-popup");
A bit naive suggestion, but there's no functionality to map the errors in this package, as far as I know. The way you're handling it seems correct to me.
I have started to use Stackmob as a backend for a simple app I am building.
In stackmob I have set a relationship between two schema's and want to use '.fetchExpanded' to grab all of the data from stackmob, see this fiddle (will need to view the console to see the output):
http://jsfiddle.net/mcneela86/65Rax/
.fetchExtended(1);
The same code works using the '.fetch' instead of '.fetchExpanded'.
Has anyone come across this before?
Would really appreciate any help.
Ok, I found a work around for this.
Instead of using '.fetchExtended(1);' I will just use '.fetch();' and when I am defining the model I will change the following:
var Bike = StackMob.Model.extend({
schemaName: "bikes"
});
to:
var Bike = StackMob.Model.extend({
schemaName: "bikes?_expand=1"
});
This seems to remove the need for '.fetchExtended(1);'
Hope this helps someone else.
I have a large complex ASP.net WebForm website that I'm working on a visual redesign and am trying to think of good ways to exercise all the code paths in the website so I can see how things look with the redesign.
For example lets say I have a message that only gets displayed if there is an error which rarely happens. Here is an example of what my code might look like:
if (someErrorCondition) {
someControl.Visible = true;
} else {
someOtherControl.Visible = true;
}
This might not be a good way of doing things, but this is a good example of my existing code base I have to work with.
Let us assume for the sake of simplicity that I already have a way of testing one part of the if. The problem is exercising the other part without going through a lot of trouble to setup my environment to create an error.
One idea I had was to extract someErrorCondition into a method and in that method check for some session or request key to see if I want to fake a failure. Maybe wrap it in an #if DEBUG block so that it won't be compiled for production.
Any other ideas for how I might go about testing unusual code blocks on an ASP.net website so I can make sure nothing got left out in the redesign?
I believe the best solution is always the most simple. Since you obviously have access to the code, do a search for the Visible property for each form element within Visual Studio and set each one to true to see how it looks. Once you make the design change then un-comment the original code.
Example:
if (someErrorCondition) {
someControl.Visible = true;
} else {
someOtherControl.Visible = true;
}
TO
/* if (someErrorCondition) {
someControl.Visible = true;
} else {
someOtherControl.Visible = true;
}*/ someControl.Visible = true;
This is not good for testing proper behavior of the form, but will let you see how each element looks for visual design purposes.
I am learning how to make firefox extensions and have gotten totally confused... so I thought I would start from the basics again.
Can you make me (or walk me through creating) a simple skeleton extension that saves "ryan" into sqlite storage, so that it is available even on the browser restart?
From there I think I can start modifying it to run all the different code that exists only in my head... and to answer my own questions :))
Thanks!
Ryan
This is even simpler if you use the Addon SDK.
var storage = require("simple-storage").storage;
if (storage.name) {
console.log (storage.name);
}
else {
console.log ("Storing!");
storage.name = "ryan";
}
This will output "Storing!" the first time it's run, and "ryan" subsequent times.
I'm working on a web app (ASP.NET) that has some features that require Microsoft Excel installed on the client. I'd like to disable those features if Excel is not present.
Windows/IE/Excel only solutions are fine. This is not a multi-browser, multi-OS web app.
Any clever JavaScript out there to accomplish this?
No.
You're not allowed to dive into the client machine deep enough to figure out that part. The best you can do is to either assume it is installed, and ponder hard about what happens if it is not, or just ask the user.
You can do something like this, but you'll get all kinds of security warnings:
<script>
var excelInstalled;
try
{
var excel = new ActiveXObject("Excel.Application");
excelInstalled = true;
}
catch(e)
{
excelInstalled = false;
}
alert("excelInstalled: " + excelInstalled);
</script>
Why Excel? What if I have OpenOffice.org instead?
Just warn the user what you're going to send them, mark the link with "Excel file", and let him decide.
function hasOfficePlugin() {
var toCheckExt = ['', '12', '13', '14', '15'], i, n, mt;
for (i = 0, n = toCheckExt.length; i < n; i++) {
mt = navigator.mimeTypes['application/x-msoffice' + toCheckExt[i]];
if (mt && mt.enabledPlugin && mt.enabledPlugin.name) {
return true;
}
}
return false;
}
I've tested the above with Office 11 (2003), and Office 12 (2007), and it seems to work well in Firefox, Safari, Chrome, and Opera. Though it doesn't work in IE, because the navigator.mimeTypes objects in IE is always empty.
It's checking for the existence of an MS Office plugin. I don't know much about this plugin - quite possibly it's not always installed with office... But I think that, if the above returns true, it's a pretty strong signal that Excel is installed. Course it's probably of limited use since it doesn't work in IE, but maybe you can do something with it...
you can not access client information outside of the web browser context, using standard technologies. but I see one of answers is using some ActivX object to detect Excel. anyway these kinds of technologies work only on Internet Explorer on windows. what about Mac? what about other browsers like opera or firefox or chrome on windows?
I think it is better to let the user inform you about this. just ask the user if she has excel installed or not:
var isExcel = window.confirm('dear user if you have Microsoft Excel installed please click on ok, otherwise click on cancel. thank you.');
This is bad idea at start. What ever you are trying to do - reconsider.
If you still insist:
Try to crete ActiveXObject for Excel and then for OpenOffice.
If it fails, redirect to NoExcel.html or send XMLRequest to server.
Also, you can try to find out via JavaScritp if there is XLS file extension handler.
And last, you can install your ActiveX which checks if Excel is installed.
This is for windows. No idea for mac, linux, mobile...
You can bet that any way you make it work will stop working with next hotfix.