selenium rc captureEntirePageScreenshotToString triggers FileNotFoundException - selenium-rc

I'm using selenium rc to do functional website testing and I've recently experienced a mysterious issue with safari and opera.
When a test fails I make a screenshot using the captureEntirePageScreenshotToString command as well as retrieving the html source.
Sometimes however this fails with a FileNotFoundException:
java.io.FileNotFoundException: C:\DOKUME~1\selenium\LOKALE~1\Temp\customProfileDir8aa20800ab1a46dbb3ef71d4d2d31b77\screenshots\page-screenshot-8aa20800ab1a46dbb3ef71d4d2d31b77.png
Is this a selenium bug? How can I workaround this issue?
I'm using selenium rc standalone 2.0a4.
thanks,
hans

So I've been using the 'captureScreenshotToString' method which is a little different, but still provides the means to get a screenshot from a remote selenium instance.
The large different/problem with this approach is that it requires the selenium server to be an unlocked windows session so it can access the display buffer to get at the physical screen. This has created problems with my headless selenium-grid machines, that I remote desktop into to administrate/troubleshoot.
In order to workaround that I've used an autologon script for this msdn article, and setup a task to restart the computer after a remote desktop session ends.
To setup Auto-Restart after remote desktop disconnect:
Open up the task scheduler
Create a new task (Create task...)
Set the name of the task to be 'Auto-Restart after remote desktop disconnect'
In the General tab, change the user to NT AUTHORITY\SYSTEM
Change to the Triggers tab, click New... to create a new trigger
Set the Begin the task to 'On disconnect from user session'
By default, it will be for any user, and from remote computers, which is exactly what we are looking for.
Change to the Actions tab, click New... to create a new action
Select the action to be Start a program. Set the program to be 'C:\Windows\System32\shutdown.exe', and then add '/r /f /t 5' (Restart, Force quit applications, wait 5 seconds to restart).
Fair warning, this is not the most secure way to have a computer sitting around

I suggest you use the Apache Commons FileUtils function makeDirs() to create all the parent directories of the directory where the png image will be located.

Related

Preventing Chrome Extension Uninstallation?

My company has Chrome with our custom extension running on windows machines.
Our goal is to launch chrome locally on our machines with our extension running at all times. Our users are constantly looking to uninstall our extension.
Our current approach is to utilize the ExtensionInstallForceList registry key. This sort of works:
Right now, one can still click into C:\WM_0.0 and delete the folder. Once the folder is deleted, this extension is gone.
So we tried the following:
Create a windows account "Client"
Assign "Client" to "Client Group"
Change the permission C:\WM_0.0 to Deny Write
Log out and login to the machine again as Client.
Once I login to my windows machine as Client, I can no longer load my extension:
I tried to change the folder's permission to Full Control for both Users and Client Group but I am still seeing this error in Chrome.
1. How can I load this extension successfully given my current set of circumstances?
2. Is there a better way to do this?

Script or executable to set homepage for default browser, and auto-load browser on PC startup

We're launching our new company intranet soon and to ensure that everyone uses it (or at least see's it), we'd like to create an automated procedure for changing the default browser's (IE11, FF, Chrome) homepage to the new URL for the intranet. We'd also like to make the browser load on computer startup.
Is there a way to do this via a batch or VB script, executable or GPO?
I had a feeling that GPO's would be the easiest way to enforce the home/start page change.
One small problem though - not all of our offices are running Server 2012 or above and some aren't even running a DC. Those few only have 3-4 staff and are just running standalone desktops.
So I was hoping to create a compressed package for them to download with a few shortcuts (.lnk), registry fixes, VB scripts and the like all to run from a single batch file.
I have the shortcut, the icon, a registry tweak for IE, a batch script for FF and I was going to create a batch file to automate the procedure. But I'm missing a start page modifier for Chrome.
And maybe there's a better way to do all of it... because the batch file will need to be run with administrative privileges.
I'd like to make it as seamless and easy as possible for those staff that are not very computer literate.
Also - one of our offices uses Macs... Is there a Mac equivalent to this? They mostly use Safari or Chrome.

Getting a Scripting.FileSystemObect error from local VBscript in IE8

I'm currently working on laptops that go in Police Cars. They run an app called IMobile which is an extension of our CAD system, and allows them to do vehicle lookups, get more info on a call, etc.
The IMobile app is basically an IE overlay and it uses htm files that are on the local laptop. We've added in some simple VBScripts that do various tasks. Some common functions that are required for these tasks are in a VBscript called PoliceFunctions.vbs which is included in the same directory as all the other scripts. This method worked fine in previous versions of IE and Windows, however we're getting scripting errors in Windows 7 with IE8, specifically, 'ActiveX component can't create object: "Scripting.FileSystemObject"' and it references the functions script mentioned above.
If I set IE's settings to allow it to run ActiveX controls not marked as safe, the script runs fine, however I don't want do open a large security hole. I've tried adding localhost and the directory to the Trusted Sites list with no effect. I've tried re-registering SCRRUN.dll as mentioned in another post as well as wscript -regserver. And I've changed IE's settings to allow local Active Content with no success.
Anyone have any other ideas of how I can allow this script to run without opening a large security hole or having it nag the end user that his IE settings are going to bring about the apocolypse?
The explanation is long but explains how IE uses security zones to make trust decisions.
The URLAction of interest in this case is:
1201 Initialize and script ActiveX controls not marked as safe(URLACTION_ACTIVEX_OVERRIDE_OBJECT_SAFETY)
The default setting for this URLAction in the Local Machine zone is Prompt, and in all other zones it is Disable. Only if you change that setting to Enable will you bypass the prompt. You cannot use the Internet Control Panel to adjust the security settings for the Local Machine zone because only the other four zones are shown in this UI. To change the setting for the Local Machine zone, you can edit the registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\0
Change the value for entry 1201 from 1 to 0
Write an ActiveX, implement IObejctSafety and wrap FSO methods in it. Note this is lying about the ActiveX's scripting safety but it is better than open to every unsafe ActiveX.
As the app "uses htm files that are on the local laptop" you could try to switch to a .hta application. For a quick test, just rename the *.html to .hta; if it 'works' add a suitable hta:application tag. To start

Full / maximised Screen Programs at start up for "vending machines / ticket machines"

Just curious about the different ways vending machine companies / ticket companies get their application to run at startup full screen on a windows host machine.
Now first thing I am thinking is obvioulsy a link to the app in startup with a switch for -fullscreen.
There would be local / group policy as another option also.
Sidetracking a bit how do apps such as Skype work when they offer the "start skype when computer starts" option? registry?
Any thoughts / ideas / experience appreciated. Cheers
There are many ways to get an app to start automatically at Windows startup. The two most popular are
putting it into the Autostart folder
writing a special registry value (there is a kind of autostart section there)
I would guess most apps use one of these mechanisms.
As to "fullscreen mode", most kiosk-type systems / vending machines use a custom software as their GUI, so I guess that is developed to always run full-screen (there is no point in running it otherwise), so there no need to configure it for full-screen mode, it will always run like that.
With windows you do not have to have explorer.exe as your "shell".
The GPO settings "User Configuration > Administrative Templates > System > Custom user interface" can be set to be what ever you want - it could be a program, or a simple batch file.
So for example, you could have a batch file that - mapped a network drive, run a program, if that program terminates, the script then restarts the computer.
You would then use autologon for that computer to logon again and start the process all over again.
Most of the software add them to startup by creating a new REG_SZ value (with application path) at one (or more) of the following locations:
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run]
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce]
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices]
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce]
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServices]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce]
[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows]
NOTE: It may also be loaded from the [Load] or [Run] sections of your
WIN.INI file, found in the Windows directory, but you should not depend on it.
To start it in MAXIMIZED mode, you can design your application to resize itself to maximize mode on startup.

How to locate a file in windows explorer

I have a application to list all music files in user machine, a "Explorer" button is using to quickly open Windows Explorer and highlight the file in Windows Explorer. I tried ShellExecute, but it doesn't work, the API will launch associate application. Any Windows API can do that? Thanks in advance.
You can simply start explorer.exe with the /select argument, as detailed in this Knowledge Base article:
Explorer /select,C:\TestDir\TestApp.exe
You can create an IE instance and navigate to your folder, then query the IShellBrowser service from the top level browser service and get the active view's IShellView interface. Use IShellView::SelectItem to select items.
Remember to call IWebBrowser::Quit when you don't need the explorer window.
This method can not get around Windows Vista's User Interface Privilege Isolation. If the folder is opened in a process with a different integrity level, a broker IE extension is needed to continue the automation.

Resources