package com.frameworkium.core.ui.browsers;

import com.frameworkium.core.ui.driver.Driver;
import org.openqa.selenium.JavascriptExecutor;

import java.util.Optional;

public class UserAgent {

    private static final String SCRIPT = "return navigator.userAgent;";

    private String userAgent;

    public UserAgent(JavascriptExecutor driver) {
        if (Driver.isNative()) {
            userAgent = null;
        } else {
            try {
                userAgent = (String) driver.executeScript(SCRIPT);
            } catch (Exception ignored) {
            }
        }
    }

    public Optional<String> getUserAgent() {
        return Optional.ofNullable(userAgent);
    }
}

@@ -41,55 +41,8 @@
 s;%0A%0A
-import com.frameworkium.core.ui.driver.Driver;%0A
 impo
@@ -84,16 +84,16 @@
 ecutor;%0A
+
 %0Aimport 
@@ -240,16 +240,23 @@
 serAgent
+ = null
 ;%0A%0A    p
@@ -304,92 +304,8 @@
 ) %7B%0A
-        if (Driver.isNative()) %7B%0A            userAgent = null;%0A        %7D else %7B%0A    
     
@@ -314,20 +314,16 @@
   try %7B%0A
-    
         
@@ -385,20 +385,16 @@
         
-    
 %7D catch 
@@ -419,22 +419,8 @@
 ) %7B%0A
-            %7D%0A
     

Fix checkstyle and make UserAgent constructor even simpler