11package com .frameworkium .capture .model ;
22
33import com .frameworkium .config .SystemProperty ;
4+ import com .frameworkium .tests .internal .BaseTest ;
5+ import net .sf .uadetector .service .UADetectorServiceFactory ;
6+ import net .sf .uadetector .UserAgentStringParser ;
7+ import net .sf .uadetector .ReadableUserAgent ;
48
59public class Browser {
610 private String name ;
@@ -10,20 +14,37 @@ public class Browser {
1014 private String platformVersion ;
1115
1216 public Browser () {
13- if (SystemProperty .BROWSER .isSpecified ()) {
14- this .name = SystemProperty .BROWSER .getValue ().toLowerCase ();
15- }
16- if (SystemProperty .BROWSER_VERSION .isSpecified ()) {
17- this .version = SystemProperty .BROWSER_VERSION .getValue ();
18- }
19- if (SystemProperty .DEVICE .isSpecified ()) {
20- this .device = SystemProperty .DEVICE .getValue ();
21- }
22- if (SystemProperty .PLATFORM .isSpecified ()) {
23- this .platform = SystemProperty .PLATFORM .getValue ();
24- }
25- if (SystemProperty .PLATFORM_VERSION .isSpecified ()) {
26- this .platformVersion = SystemProperty .PLATFORM_VERSION .getValue ();
17+
18+
19+ if (!BaseTest .userAgent .isEmpty ()) {
20+ // Get an UserAgentStringParser and analyze the requesting client
21+ UserAgentStringParser parser = UADetectorServiceFactory .getResourceModuleParser ();
22+ ReadableUserAgent agent = parser .parse (BaseTest .userAgent );
23+
24+ //Set the params based on this agent
25+ this .name = agent .getName ();
26+ this .version = agent .getVersionNumber ().toVersionString ();
27+ this .device = agent .getDeviceCategory ().getName ();
28+ this .platform = agent .getOperatingSystem ().getName ();
29+ this .platformVersion = agent .getOperatingSystem ().getVersionNumber ().toVersionString ();
30+
31+ } else {
32+
33+ if (SystemProperty .BROWSER .isSpecified ()) {
34+ this .name = SystemProperty .BROWSER .getValue ().toLowerCase ();
35+ }
36+ if (SystemProperty .BROWSER_VERSION .isSpecified ()) {
37+ this .version = SystemProperty .BROWSER_VERSION .getValue ();
38+ }
39+ if (SystemProperty .DEVICE .isSpecified ()) {
40+ this .device = SystemProperty .DEVICE .getValue ();
41+ }
42+ if (SystemProperty .PLATFORM .isSpecified ()) {
43+ this .platform = SystemProperty .PLATFORM .getValue ();
44+ }
45+ if (SystemProperty .PLATFORM_VERSION .isSpecified ()) {
46+ this .platformVersion = SystemProperty .PLATFORM_VERSION .getValue ();
47+ }
2748 }
2849 }
2950
0 commit comments