Skip to content

Commit 30f2a9a

Browse files
committed
Merge pull request #11 from robertgates55/rga-useragent-mods
Resolved issue collecting userAgent on startup, and added user agent …
2 parents 80f12d8 + eef8086 commit 30f2a9a

File tree

3 files changed

+43
-15
lines changed

3 files changed

+43
-15
lines changed

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@
135135
<artifactId>ngwebdriver</artifactId>
136136
<version>0.9.1</version>
137137
</dependency>
138+
<dependency>
139+
<groupId>net.sf.uadetector</groupId>
140+
<artifactId>uadetector-resources</artifactId>
141+
<version>2014.04</version>
142+
</dependency>
138143
</dependencies>
139144

140145
<repositories>

src/main/java/com/frameworkium/capture/model/Browser.java

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package com.frameworkium.capture.model;
22

33
import 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

59
public 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

src/main/java/com/frameworkium/listeners/CaptureListener.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ public void beforeNavigateTo(String url, WebDriver driver) {
9999

100100
@Override
101101
public void beforeScript(String script, WebDriver driver) {
102-
takeScreenshotAndSendToCapture("script", driver);
102+
if(!script.contains("navigator.userAgent")){
103+
takeScreenshotAndSendToCapture("script", driver);
104+
}
103105
}
104106

105107
/* Test end methods */

0 commit comments

Comments
 (0)