Overview
Concrete enum for representing known microprocessor architectures provided by the Selenium WebDriver library.
Description
Architecture is an enum that represents known CPU architectures used in the WebDriver ecosystem. It smooths over Java's rough edges when dealing with microprocessor architectures by grouping related architecture identifiers into families. For example, X86 matches "x86", "i386", "ia32", "i686", "i486", "i86", "pentium", and related names. Each architecture family can report its data model (32-bit or 64-bit). The enum also provides a special ANY value that matches any architecture, and a static method extractFromSysProperty() to resolve a system property string into the appropriate enum constant. The defined architecture families are: X86 (32-bit), X64 (64-bit), ARM (64-bit), MIPS32 (32-bit), MIPS64 (64-bit), and ANY (wildcard).
Usage
Use Architecture when you need to identify or compare processor architectures in the context of Selenium Grid node capabilities, platform detection, or driver binary selection. It is commonly used alongside Platform to describe system capabilities.
Code Reference
Source Location
Signature
public enum Architecture {
X86("x86", "i386", "ia32", "i686", "i486", "i86",
"pentium", "pentium_pro", "pentium_pro+mmx", "pentium+mmx"),
X64("amd64", "ia64", "x86_64"),
ARM("aarch64", "arm"),
MIPS32("mips32"),
MIPS64("mips64"),
ANY("");
public boolean is(Architecture compareWith)
public int getDataModel()
public static Architecture getCurrent()
public static Architecture extractFromSysProperty(String arch)
@Override public String toString()
}
Import
import org.openqa.selenium.Architecture;
I/O Contract
| Enum Constant |
Identifiers |
Data Model
|
X86 |
x86, i386, ia32, i686, i486, i86, pentium, pentium_pro, pentium_pro+mmx, pentium+mmx |
32-bit
|
X64 |
amd64, ia64, x86_64 |
64-bit
|
ARM |
aarch64, arm |
64-bit
|
MIPS32 |
mips32 |
32-bit
|
MIPS64 |
mips64 |
64-bit
|
ANY |
(empty) |
64-bit (default)
|
| Method |
Return Type |
Description
|
is(Architecture) |
boolean |
Returns true if this architecture is the same as the given one; ANY always returns true
|
getDataModel() |
int |
Returns 32 or 64 depending on architecture family
|
getCurrent() |
Architecture |
Static method that returns the architecture of the current JVM (from os.arch)
|
extractFromSysProperty(String) |
Architecture |
Static method that resolves an architecture name string to the matching enum constant
|
toString() |
String |
Returns the lowercase name of the enum constant
|
| Exception Condition |
Exception Type |
Description
|
| Unknown architecture string |
UnsupportedOperationException |
Thrown by extractFromSysProperty() when the given arch string does not match any known architecture
|
Usage Examples
// Get the architecture of the current system
Architecture current = Architecture.getCurrent();
System.out.println("Current architecture: " + current); // e.g., "x64"
// Check the data model (32-bit vs 64-bit)
int dataModel = current.getDataModel(); // 32 or 64
// Extract architecture from a string
Architecture arch = Architecture.extractFromSysProperty("amd64");
System.out.println(arch); // "x64"
// Compare architectures
boolean isX64 = arch.is(Architecture.X64); // true
// ANY matches everything
boolean matchesAny = Architecture.ANY.is(Architecture.X86); // true
// Use in capability matching for Selenium Grid
Architecture nodeArch = Architecture.extractFromSysProperty("x86_64");
if (nodeArch.is(Architecture.X64)) {
System.out.println("64-bit node available");
}
// Handle unknown architecture gracefully
try {
Architecture unknown = Architecture.extractFromSysProperty("sparc");
} catch (UnsupportedOperationException e) {
System.out.println("Architecture not supported: " + e.getMessage());
}
Related Pages