Detect if an alert or confirm is displayed on a page

If you wanted to run some code when an alert() fires, you could try something like this: I’ve only tested in Chrome, so I’m not sure about browser support. Example: http://jsfiddle.net/Q785x/1/ (function() { var _old_alert = window.alert; window.alert = function() { // run some code when the alert pops up document.body.innerHTML += “<br>alerting”; _old_alert.apply(window,arguments); // … Read more

Can I prevent an alert() with a Google Chrome Extension

As @MrGlass said, currently, Chrome Extensions run in a separate environment, limiting access to the actual window object and providing a duplicate that is only valid for the extension. To solve this, we can inject a script element directly into the document. This way, you access the document’s environment and the real window object. First, … Read more

How to get Text BOLD in Alert or Confirm box?

You can’t do it. But you can use custom Alert and Confirm boxes. You can read about some User Interface libraries here: http://speckyboy.com/2010/05/17/15-javascript-web-ui-libraries-frameworks-and-libraries/ Most common libraries are: http://jqueryui.com/ http://mootools.net/ http://www.prototype-ui.com/ http://script.aculo.us/ http://developer.yahoo.com/yui/

How do I recover the “text” from the page originating the alert, esp **after** the human user has *clicked* [dismiss] on the page’s **alert**?

I have been struggling with this issue off and on for a long time; your comment on your question solved the problem for me: After both UnexpectedAlertPresentException and NoAlertPresentException are thrown… browser.execute_script(‘alert(“Clearing out past dialogs.”)’) browser.switch_to.alert.accept() As you said in your answer, webdriver is creating a ‘dialog’ when the alert is present. Closing the alert … Read more

Android saving Bitmap to SD card

try this private void SaveImage(Bitmap finalBitmap) { String root = Environment.getExternalStorageDirectory().toString(); File myDir = new File(root + “/saved_images”); myDir.mkdirs(); Random generator = new Random(); int n = 10000; n = generator.nextInt(n); String fname = “Image-“+ n +”.jpg”; File file = new File (myDir, fname); if (file.exists ()) file.delete (); try { FileOutputStream out = new … Read more