private static string GetAutomation(ISearchContext context)
        {
            IWebDriver driver = WebDriverUnpackUtility.
                                UnpackWebdriver(context);

            if (driver == null)
            {
                return(null);
            }

            if (typeof(IHasCapabilities).IsAssignableFrom(driver.GetType()))
            {
                IHasCapabilities hasCapabilities = (IHasCapabilities)driver;
                object           automation      = hasCapabilities.
                                                   Capabilities.GetCapability(MobileCapabilityType.AutomationName);

                if (automation == null || String.IsNullOrEmpty(Convert.ToString(automation)))
                {
                    automation = hasCapabilities.Capabilities.GetCapability(CapabilityType.BrowserName);
                }

                string convertedAutomation = Convert.ToString(automation);
                if (automation != null && !String.IsNullOrEmpty(convertedAutomation))
                {
                    return(convertedAutomation);
                }
            }
            return(null);
        }
Example #2
0
        private static string GetPlatform(ISearchContext context)
        {
            IWebDriver driver = WebDriverUnpackUtility.UnpackWebdriver(context);

            if (driver == null)
            {
                return(null);
            }

            Type driverType = driver.GetType();

            if (GenericsUtility.MatchGenerics(typeof(AndroidDriver <>),
                                              AppiumPageObjectMemberDecorator.ListOfAvailableElementTypes, driverType))
            {
                return(MobilePlatform.Android);
            }

            if (GenericsUtility.MatchGenerics(typeof(IOSDriver <>),
                                              AppiumPageObjectMemberDecorator.ListOfAvailableElementTypes, driverType))
            {
                return(MobilePlatform.IOS);
            }

            if (GenericsUtility.MatchGenerics(typeof(WindowsDriver <>),
                                              AppiumPageObjectMemberDecorator.ListOfAvailableElementTypes, driverType))
            {
                return(MobilePlatform.Windows);
            }

            if (typeof(IHasCapabilities).IsAssignableFrom(driverType))
            {
                IHasCapabilities hasCapabilities = (IHasCapabilities)driver;
                object           platform        = hasCapabilities.Capabilities.GetCapability(MobileCapabilityType.PlatformName);

                if (platform == null || string.IsNullOrEmpty(Convert.ToString(platform)))
                {
                    platform = hasCapabilities.Capabilities.GetCapability(CapabilityType.Platform);
                }

                string convertedPlatform = Convert.ToString(platform);
                if (platform != null && !string.IsNullOrEmpty(convertedPlatform))
                {
                    return(convertedPlatform);
                }
            }
            return(null);
        }
Example #3
0
        private IEnumerable <By> GetReturnRelevantBys(ISearchContext context)
        {
            IWebDriver driver = WebDriverUnpackUtility.UnpackWebdriver(context);

            if (!typeof(IContextAware).IsAssignableFrom(driver.GetType())) //it is desktop browser
            {
                return(map[ContentTypes.HTML]);
            }

            IContextAware contextAware   = driver as IContextAware;
            string        currentContext = contextAware.Context;

            if (currentContext.Contains(NATIVE_APP_PATTERN))
            {
                return(map[ContentTypes.NATIVE]);
            }

            return(map[ContentTypes.HTML]);
        }