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) {
        userAgent = determineUserAgent(driver);
    }

    private String determineUserAgent(JavascriptExecutor driver) {
        if (!Driver.isNative()) {
            try {
                return (String) driver.executeScript(SCRIPT);
            } catch (Exception ignored) {
            }
        }
        return null;
    }

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

@@ -352,153 +352,77 @@
     
-userAgent = determineUserAgent(driver);
+if (Driver.isNative()) %7B
 %0A    
-%7D%0A%0A
     
-private String determineUserAgent(JavascriptExecutor driver) %7B%0A        if (!Driver.isNative())
+    userAgent = null;%0A        %7D else
  %7B%0A 
@@ -454,22 +454,27 @@
         
-return
+userAgent =
  (String
@@ -575,29 +575,8 @@
   %7D%0A
-        return null;%0A
     

Simplify UserAgent code