Selenium : System Information
- System.getProperty("os.name")
- System.out.print((RemoteWebDriver) driver).getCapabilities().toString())
---------------------------------------------------------------------------------------------------
/Created By:Deepak
//how to use : 1.Send your driver as arguement
// This function returns dictionary
variable .
//
sys_info.get("browserName");
// sys_info.get("version");
// sys_info.get("os_name");
//
sys_info.get("os_version");
static Dictionary system_info(WebDriver driver)
{
String browsername="",version="";
System.out.println(System.getProperty("os.name"));
String[] a=((RemoteWebDriver)
driver).getCapabilities().toString().split(",");
for(int i=0;i<=a.length-1;i++){
if(a[i].contains("browserName"))
browsername=a[i];
else if(a[i].contains("version"))
version=a[i];
}
Dictionary sys_info=new Hashtable();
sys_info.put("browserName", browsername);
sys_info.put("version", version);
sys_info.put("os_name", System.getProperty("os.name"));
sys_info.put("os_version",System.getProperty("os.version"));
return sys_info;
}
-----------------------------------------------------------------------------------------
No comments:
Post a Comment