Search in sources :

Example 1 with OsBrowserType

use of com.testsigma.automator.entity.OsBrowserType in project testsigma by testsigmahq.

the class LinuxBrowsers method getBrowserList.

public ArrayList<AgentBrowser> getBrowserList() {
    ArrayList<AgentBrowser> browserList = new ArrayList<>();
    for (OsBrowserType browserType : browsersMap.keySet()) {
        String browserName = browsersMap.get(browserType);
        ArrayList<String> arrayList = getCommandOutput(new String[] { "which", browserName });
        if (arrayList.size() > 0) {
            if (!arrayList.get(0).contains("which: no " + browserName + " in")) {
                String version = "";
                ArrayList<String> versionOutput;
                log.debug("Fetching browser version for " + browserType.name() + " with ordinal: " + browserType.getValue());
                switch(browserType.getValue()) {
                    case 1:
                        log.debug("Fetching linux browsers version....chrome version");
                        versionOutput = getCommandOutput(new String[] { arrayList.get(0), "--product-version" });
                        version = versionOutput.get(0);
                        break;
                    case 2:
                        log.debug("Fetching linux browsers version....firefox version");
                        versionOutput = getCommandOutput(new String[] { arrayList.get(0), "-v" });
                        Pattern pattern = Pattern.compile("^[\\D\\s]*([0-9.]+)[\\D\\s]*$");
                        Matcher matcher = pattern.matcher(versionOutput.get(0));
                        if (matcher.find()) {
                            version = matcher.group(1);
                        }
                        break;
                }
                log.debug("Found version - " + version);
                try {
                    browserList.add(new AgentBrowser(browserType, version, 0));
                } catch (Exception e) {
                    log.info("Ignoring browser because of bellow error");
                    log.error(e, e);
                }
            }
        }
    }
    return browserList;
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) OsBrowserType(com.testsigma.automator.entity.OsBrowserType)

Example 2 with OsBrowserType

use of com.testsigma.automator.entity.OsBrowserType in project testsigma by testsigmahq.

the class DeviceContainer method syncBrowserDrivers.

public void syncBrowserDrivers(MobileDevice mobileDevice) {
    log.info("Syncing Browser Drivers For Mobile Devices - " + mobileDevice);
    List<AgentBrowser> browserList = mobileDevice.getBrowserList();
    if (browserList == null) {
        return;
    }
    for (AgentBrowser browserObj : browserList) {
        try {
            log.info("Trying to sync driver for mobile browser - " + browserObj);
            OsBrowserType browserType = browserObj.getName();
            String browserVersion = browserObj.getMajorVersion() + "";
            Browsers browser = OsBrowserType.getBrowserType(browserType);
            String driverPath = AutomatorConfig.getInstance().getAppBridge().getDriverExecutablePath(browser.getKey(), browserVersion);
            new DriversUpdateService().syncBrowserDriver(browserType, browserVersion, driverPath);
        } catch (AutomatorException e) {
            log.error(e.getMessage(), e);
        }
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) AgentBrowser(com.testsigma.agent.browsers.AgentBrowser) Browsers(com.testsigma.automator.entity.Browsers) DriversUpdateService(com.testsigma.automator.drivers.DriversUpdateService) OsBrowserType(com.testsigma.automator.entity.OsBrowserType)

Aggregations

OsBrowserType (com.testsigma.automator.entity.OsBrowserType)2 AgentBrowser (com.testsigma.agent.browsers.AgentBrowser)1 DriversUpdateService (com.testsigma.automator.drivers.DriversUpdateService)1 Browsers (com.testsigma.automator.entity.Browsers)1 AutomatorException (com.testsigma.automator.exceptions.AutomatorException)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1