While you browse in a gui's activex control shell.explorer, sometimes the page has an script error and a message appears saying there was an error and stopping the program. How can I block these messages from the activex? I know I can in IE, in the settings menu or somewhere and I did it but it doesn't apply for activex control as it runs separately from IE (if you login somewhere in IE you also have to login on the activex, for example)
Sorry I found out what I wanted. I wanted to turn off the annoying script error messages and you can do so with IEObj.silent:=1
Related
I recently blocked quite a lot of ads across my entire network using AdGuard. Unfortunately, AdGuard does not prevent pop-up windows from opening. Although the advertising page is not called up, I get a popup which tells me that the requested page cannot be reached.
That's why I wanted to write a chrome extension that closes these popups automatically. Unfortunately, I fail to save the value of a checkbox in chrome.storage that is supposed to activate / deactivate the extension.
could someone help me here?
:EDIT
Okay i managed to store my value but now i'm running into the problem that i need to run a script when a page can't be loaded and i got no idea how i can do that. :S
Any Ideas? Is that even possible?
I'm using Selenium with VBA and Microsoft Edge to collect information, and download some files from a webpage. Everything works great except for the downloading part.
On this example site: https://file-examples.com/index.php/sample-documents-download/sample-doc-download/, Code like
oWebDriver.FindElementByXPath("//a[#href=""https://file-examples-com.github.io/uploads/2017/02/file-sample_100kB.doc""]").Click
will result in a popup like this:
Unfortunately, it is not possible to simply change the browser's preferences in my case, because the macro will be running on a machine with limited authorization and the following setting can not be changed:
The last option can be translated to: "Ask for the storage location with every download" and it is locked.
It seems that the "Save As" popup in the first screenshot can't be accessed, neither with Selenium nor with SendKeys.
So the only option seems to be using the Windows API with VBA to somehow automate this step, however, even so, it seems to be impossible to get a handle on this pesky popup. I tried finding the window with Spy++ and it doesn't seem to show up as a separate window:
The only solution I can now think of is getting the window size of the parent Edge browser window, navigating the mouse to the approximate position of the "Save As" button, and clicking it there using VBA and the Windows API. Obviously, This is not a great solution, as it would be quite frail and can easily break with the smallest misalignment.
Is there any other way to automate this step that doesn't require moving the mouse and automating the "manual" clicking, using only VBA with Selenium?
Selenium only works for browser web page automation. The pop-up is not a part of the wab page so Selenium will not be able to recognize it.
And I think any setting in Selenium including "download.prompt_for_download" won't have effect. The pop-up is controlled by the browser setting, and the browser setting is controlled by your group policy, you can't override it with Selenium settings.
I think the only way is to use some 3rd party UI automation library to click that option along with Selenium, just like what you said in the question.
When there's a problem in the content or background script, I do not get any error messages outputted in the console. Neither will it print anything to the console via console.log('msg'). except when I do alert() explicitly.
I am copying and pasting the javascript in the console manually to catch errors, but there must be a better way of debugging a chrome extension script.
There are two consoles, one for your popup and one for the background pages. You're probably looking at the wrong one.
You can access the popup console by right clicking your extension's icon and selecting Inspect Popup and clicking the console tab in the top right.
You can access the background console by going to chrome://extensions and selecting Background Page which is to the right of Inspect views by your extension.
Make sure you're in developer mode. If you're not sure how to enter that, check out https://developer.chrome.com/extensions/getstarted
Implementing Webbrowser control in MFC VC++ application. when there are script errors on the page it displays all the time even when I un-select "Display a notification about every script error" in Internet Explorer. This control inherits the other options like "Show Images" from IE but not script errors.
I tried to debug "OnNavigateError()" and "OnNewBrowserWindow()" events but it still does not come here. I know in C# there is a property called "ScriptErrorsSuppressed" to disable script error in webbrowser control but how to do it in VC++. please help.
Please be aware that you can never catch all errors and you should also consider displaying these annoying messages. After all, a WebBrowser control is not a browser and is used, many times, for a limited purpose (for example: I am using such for a mapping project). So you can just turn these messages off by calling:
m_Browser.put_Silent(TRUE);
You need to read the MSDN article: How to handle script errors as a WebBrowser control host and add several include files
#include <Docobj.h>
#include <Mshtml.h>
And finally define:
DEFINE_GUID(CGID_DocHostCommandHandler,0xf38bc242,0xb950,0x11d1,0x89,0x18,0x00,0xc0,0x4f,0xc2,0xc8,0x36);
MSDN provides some information on How to handle script errors as a WebBrowser control host. That information worked for me.
I am working on an application which has got light box on the Home page, I need to close the light box and navigate to the Home Page, I am closing the Light box with the script and navigating to the Home page.
I am trying to bring the application to front and maximize the window.
I am using commands "ie.bring_to_front" and "ie.maximize".
These commands work for an application which has not got light box on the Home page.
Is it due to the Light box which is present on the home or is it due to java script the page has got.
Please suggest
Thanks and Regards,
Ajazz.
It is not possible to assist you.
Without seeing the code that is actually running on that page, and with no indication of the failure mode beyond 'not working' (e.g. what actually happens, do you get an error message of any sort?) no description of the 'light box' application, not even a screenshot, it's nearly impossible to know what is causing the code to fail. ESPECIALLY since we know the code is not at fault since it works on other sites.
Please find a psychic who can read your mind and get the information needed to help you, since you seem to be incapable of providing it when requested