The WindowsUtils class provides various methods to interact with the registry on the Windows operating system. While running tests on the Windows operating system and Internet Explorer, the test might need to read and modify IE settings or there may be a need to get some settings related to the web server or database from the registry in tests, or if you simply want to store and read values from registry. The WindowsUtils class comes handy in these situations.

Read a Windows registry value

We need to import the org.openqa.selenium.os.WindowsUtils class and use the readStringRegistryValue() method for reading a registry value that is represented as a String.

String osname = WindowsUtils.readStringRegistryValue

The WindowsUtils class interacts with the OS to get these values from registry keys. In this example, we are reading the name of the OS, which is represented as a String.
If the data type is Integer then we can use the readIntegerRegistryValue() method and for Boolean, we can use readBooleanRegistryValue().

Modifying a Windows registry value

The WindowsUtils class also provides methods to update existing Windows registry values or create new registry keys and values.

Use the writeStringRegistryValue() method for modifying existing Windows registry value or creating a new key and value represented as a string.

WindowsUtils.writeStringRegistryValue(“HKEY_CURRENT_USER\\SOFTWARE\\Selenium\\SeleniumVersion”, “2.37”);

The WindowsUtils class provides multiple methods based on value type such as writeIntegerRegistryValue() for integer values and writeBooleanRegistryValue() for Boolean data type.

Posted By István Lackó

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>