public void UsingFindElement_NoCallIsMadeFromTheDriverWithAFoundRootElement(
            [Values] LocatorType childLocatorType)
        {
            // Arrange
            TestBlock block = new TestBlock(this.rootElement);

            this.findElementMethodLookup.TryGetValue(childLocatorType, out Func <TestBlock, IWebElement> method);

            // Act
            IWebElement element = method(block);

            // Log
            TestContext.WriteLine(element.Text);
            var driverCalls = Fake.GetCalls(this.driver).Where(c => c.Method.Name.StartsWith("FindElement")).ToList();

            TestContext.WriteLine($"There were {driverCalls.Count} call(s) to the IWebDriver.");
            foreach (var call in driverCalls)
            {
                TestContext.WriteLine($"The method called on the IWebDriver was {call.Method.Name}({call.ArgumentsAfterCall[0]})");
            }

            // Assert
            using (new AssertionScope())
            {
                driverCalls.Count.Should().Be(0);
            }
        }
Exemplo n.º 2
0
        public void UsingFindElements_AnAtomicCallIsMadeWhenBothLocatorsAreSubAtomic(
            [Values] LocatorType rootLocatorType,
            [Values] LocatorType childLocatorType)
        {
            // Arrange
            bool      expectedAtomicCall = rootLocatorType.IsSubAtomic() && childLocatorType.IsSubAtomic();
            TestBlock block = GetBlockDefinedByLocatorType(rootLocatorType);

            this.findElementsMethodLookup.TryGetValue(childLocatorType, out Func <TestBlock, ReadOnlyCollection <IWebElement> > method);

            // Act
            ReadOnlyCollection <IWebElement> elements = method(block);

            // Log
            TestContext.WriteLine(elements[0]?.Text);

            // Assert
            using (new AssertionScope())
            {
                elements.Count.Should().Be(1);
                elements[0].Should().Be(expectedAtomicCall ?
                                        this.elementInElementsReturnedByDriver :
                                        this.elementInElementsReturnedByFoundElement,
                                        "the wrong IWebElement was returned.");
            }
        }
Exemplo n.º 3
0
        //Method to check if existence of an element on current page
        public static bool ExistsElement(IWebDriver driver, LocatorType locatortype, string locator)
        {
            try
            {
                switch (locatortype)
                {
                case LocatorType.Id: driver.FindElement(By.Id(locator)); break;

                case LocatorType.Name: driver.FindElement(By.Name(locator)); break;

                case LocatorType.CssSelector: driver.FindElement(By.CssSelector(locator)); break;

                case LocatorType.ClassName: driver.FindElement(By.ClassName(locator)); break;

                case LocatorType.XPath: driver.FindElement(By.XPath(locator)); break;

                case LocatorType.PartialLinkText: driver.FindElement(By.PartialLinkText(locator)); break;

                case LocatorType.TagName: driver.FindElement(By.TagName(locator)); break;
                }
            }
            catch (NoSuchElementException e)
            {
                return(false);
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 4
0
        public static ReadOnlyCollection <IWebElement> FindElements(LocatorType by, string locator)
        {
            // // loggerInfo.Instance.LogInfo("Find Elements By [ " + by + " ]" + " Locator [ " + locator + " ]");
            IWebElement parentElement = null;

            return(FindElements(by, locator, testTimeout, parentElement));
        }
Exemplo n.º 5
0
            /// <summary>
            ///     Adds the specified locator to the locators list if the return value is not null.
            /// </summary>
            /// <param name="locatorsToAdd">The locator.</param>
            /// <param name="lookup">The lookup.</param>
            /// <param name="key">The key.</param>
            private static void Add(IReadOnlyCollection <LocatorProperties> locatorsToAdd,
                                    ref Dictionary <LocatorType, IReadOnlyCollection <LocatorProperties> > lookup,
                                    LocatorType key)
            {
                if (locatorsToAdd == null)
                {
                    return;
                }

                locatorsToAdd = locatorsToAdd.ToList();

                if (!locatorsToAdd.Any())
                {
                    return;
                }

                if (!lookup.ContainsKey(key))
                {
                    lookup.Add(key, locatorsToAdd);
                }
                else
                {
                    lookup[key] = lookup[key].Concat(locatorsToAdd).ToArray();
                }
            }
        //public ReadOnlyCollection<SeleniumWebButton> MoveToNextMonth()
        //{
        //    return Utility.GetControlsFromWebElements(aWebElement.FindElements(By.TagName("a")), ControlType.Button, controlAccess).Cast<SeleniumWebButton>().ToList().AsReadOnly();
        //}

        public SeleniumWebControls GetCalenderHeader(string locator, LocatorType locatorType)
        {
            switch (locatorType)
            {
            case LocatorType.ClassName:
                return((SeleniumWebControls)Utility.GetControlFromWebElement(aWebElement.FindElement(By.ClassName(locator)), ControlType.Custom, controlAccess));

            case LocatorType.Css:
                return((SeleniumWebControls)Utility.GetControlFromWebElement(aWebElement.FindElement(By.CssSelector(locator)), ControlType.Custom, controlAccess));

            case LocatorType.Id:
                return((SeleniumWebControls)Utility.GetControlFromWebElement(aWebElement.FindElement(By.Id(locator)), ControlType.Custom, controlAccess));

            case LocatorType.LinkText:
                return((SeleniumWebControls)Utility.GetControlFromWebElement(aWebElement.FindElement(By.LinkText(locator)), ControlType.Custom, controlAccess));

            case LocatorType.Name:
                return((SeleniumWebControls)Utility.GetControlFromWebElement(aWebElement.FindElement(By.Name(locator)), ControlType.Custom, controlAccess));

            case LocatorType.PartialLinkText:
                return((SeleniumWebControls)Utility.GetControlFromWebElement(aWebElement.FindElement(By.PartialLinkText(locator)), ControlType.Custom, controlAccess));

            case LocatorType.Xpath:
                return((SeleniumWebControls)Utility.GetControlFromWebElement(aWebElement.FindElement(By.XPath(locator)), ControlType.Custom, controlAccess));

            default:
                return((SeleniumWebControls)Utility.GetControlFromWebElement(aWebElement.FindElement(By.TagName(locator)), ControlType.Custom, controlAccess));
            }
        }
        //Method to check if existence of an element on current page
        public static bool ExistsElement(IWebDriver driver, LocatorType locatortype, string locator)
        {
            try
            {
                switch (locatortype)
                {
                    case LocatorType.Id: driver.FindElement(By.Id(locator)); break;
                    case LocatorType.Name: driver.FindElement(By.Name(locator)); break;
                    case LocatorType.CssSelector: driver.FindElement(By.CssSelector(locator)); break;
                    case LocatorType.ClassName: driver.FindElement(By.ClassName(locator)); break;
                    case LocatorType.XPath: driver.FindElement(By.XPath(locator)); break;
                    case LocatorType.PartialLinkText: driver.FindElement(By.PartialLinkText(locator)); break;
                    case LocatorType.TagName: driver.FindElement(By.TagName(locator)); break;

                }

            }
            catch (NoSuchElementException e)
            {
                return false;
            }
            catch (Exception e)
            {
                return false;
            }
            return true;
        }
 /// <summary>
 /// Returns a new <see cref="ILocator"/> instance.
 /// </summary>
 /// <param name="locators">The <see cref="LocatorBaseCollection"/> instance.</param>
 /// <param name="locatorType">The <see cref="LocatorType"/>.</param>
 /// <param name="asset">The <see cref="IAsset"/> instance for the new <see cref="ILocator"/>.</param>
 /// <param name="permissions">The <see cref="AccessPermissions"/> of the <see cref="IAccessPolicy"/> associated with the new <see cref="ILocator"/>.</param>
 /// <param name="duration">The duration of the <see cref="IAccessPolicy"/> associated with the new <see cref="ILocator"/>.</param>
 /// <param name="startTime">The start time of the new <see cref="ILocator"/>.</param>
 /// <returns>A a new <see cref="ILocator"/> instance.</returns>
 public static ILocator Create(this LocatorBaseCollection locators, LocatorType locatorType, IAsset asset, AccessPermissions permissions, TimeSpan duration, DateTime?startTime)
 {
     using (Task <ILocator> task = locators.CreateAsync(locatorType, asset, permissions, duration, startTime))
     {
         return(task.Result);
     }
 }
Exemplo n.º 9
0
        public PublishStatus GetPublishedStatus(LocatorType LocType)
        {
            PublishStatus LocPubStatus;

            // if there is one locato for this type
            if ((SelectedAssets.FirstOrDefault().Locators.Where(l => l.Type == LocType).Count() > 0))
            {
                if (!SelectedAssets.FirstOrDefault().Locators.Where(l => (l.Type == LocType)).All(l => (l.ExpirationDateTime < DateTime.UtcNow)))
                {// not all int the past
                    var query = SelectedAssets.FirstOrDefault().Locators.Where(l => ((l.Type == LocType) && (l.ExpirationDateTime > DateTime.UtcNow) && (l.StartTime != null)));
                    // if no locator are valid today but at least one will in the future
                    if (query.ToList().Count() > 0)
                    {
                        LocPubStatus = (query.All(l => (l.StartTime > DateTime.UtcNow))) ? PublishStatus.PublishedFuture : PublishStatus.PublishedActive;
                    }
                    else
                    {
                        LocPubStatus = PublishStatus.PublishedActive;
                    }
                }
                else      // if all locators are in the past
                {
                    LocPubStatus = PublishStatus.PublishedExpired;
                }
            }
            else
            {
                LocPubStatus = PublishStatus.NotPublished;
            }

            return(LocPubStatus);
        }
        public void UsingFindElement_TheCorrectCallIsMadeFromTheDriver(
            [Values] LocatorType rootLocatorType,
            [Values] LocatorType childLocatorType)
        {
            // Arrange
            bool      expectedAtomicCall = rootLocatorType.IsSubAtomic() && childLocatorType.IsSubAtomic();
            TestBlock block = GetBlockDefinedByLocatorType(rootLocatorType);

            this.findElementMethodLookup.TryGetValue(childLocatorType, out Func <TestBlock, IWebElement> method);

            // Act
            _ = method(block);

            // Log
            var driverCalls = Fake.GetCalls(this.driver).Where(c => c.Method.Name.StartsWith("FindElement")).ToList();

            TestContext.WriteLine($"There were {driverCalls.Count} call(s) to the IWebDriver.");
            foreach (var call in driverCalls)
            {
                TestContext.WriteLine($"The method called on the IWebDriver was {call.Method.Name}({call.ArgumentsAfterCall[0]})");
            }

            // Assert
            using (new AssertionScope())
            {
                driverCalls.Count.Should().Be(1);
                if (expectedAtomicCall)
                {
                    driverCalls[0].ArgumentsAfterCall[0].ToString().Should().StartWith("By.CssSelector");
                }
            }
        }
Exemplo n.º 11
0
        internal static By GetByFromLocator(LocatorType locatorType, string locator)
        {
            switch (locatorType)
            {
            case LocatorType.ClassName:
                return(By.ClassName(locator));

            case LocatorType.Css:
                return(By.CssSelector(locator));

            case LocatorType.Id:
                return(By.Id(locator));

            case LocatorType.LinkText:
                return(By.LinkText(locator));

            case LocatorType.Name:
                return(By.Name(locator));

            case LocatorType.PartialLinkText:
                return(By.PartialLinkText(locator));

            case LocatorType.TagName:
                return(By.TagName(locator));

            case LocatorType.Xpath:
                return(By.XPath(locator));

            default:
                return(By.XPath(locator));
            }
        }
Exemplo n.º 12
0
        public static IWebElement FindElement(LocatorType by, string locator, int timeOut, IWebElement parentElement = null)
        {
            ReadOnlyCollection <IWebElement> SearchElements = FindElements(by, locator, timeOut, parentElement);

            if (SearchElements != null)
            {
                if (SearchElements.Count > 0)
                {
                    // // loggerInfo.Instance.LogInfo("Found Element By [ " + by + " ]" + " Locator [ " + locator + " ]");
                    return(SearchElements.First <IWebElement>());
                }
                else
                {
                    PromptAlertMessage("Unable to find Element By [ " + by + " ]" + " Locator [ " + locator + " ]");
                    // // loggerInfo.Instance.LogAppErro(new Exception("Unable to find Element By [ " + by + " ]" + " Locator [ " + locator + " ]"), "", NLog.LogLevel.Error);
                    TakeScreenShot(testEInfo);
                    return(null);
                }
            }
            else
            {
                PromptAlertMessage("Unable to Error Message is Element By [ " + by + " ]" + " Locator [ " + locator + " ]");
                // // loggerInfo.Instance.LogAppErro(new Exception("Unable to Error Message is Element By [ " + by + " ]" + " Locator [ " + locator + " ]"), "", NLog.LogLevel.Error);
                TakeScreenShot(testEInfo);
                return(null);
            }
        }
        public void UsingFindElement_ACallIsMadeFromTheReturnedElementOnlyOnNonAtomicCalls(
            [Values] LocatorType rootLocatorType,
            [Values] LocatorType childLocatorType
            )
        {
            // Arrange
            bool      expectedAtomicCall = rootLocatorType.IsSubAtomic() && childLocatorType.IsSubAtomic();
            TestBlock block = GetBlockDefinedByLocatorType(rootLocatorType);

            this.findElementMethodLookup.TryGetValue(childLocatorType, out Func <TestBlock, IWebElement> method);

            // Act
            _ = method(block);

            // Log
            var returnedElementCalls = Fake.GetCalls(this.elementReturnedByDriver).Where(c => c.Method.Name.StartsWith("FindElement")).ToList();

            TestContext.WriteLine($"There were {returnedElementCalls.Count} call(s) to the returned Element.");
            foreach (var call in returnedElementCalls)
            {
                TestContext.WriteLine($"The Call made to the returnedElement was {call.Method.Name}({call.ArgumentsAfterCall[0]})");
            }

            // Assert
            returnedElementCalls.Count.Should().Be(expectedAtomicCall ? 0 : 1);
        }
Exemplo n.º 14
0
        public static IWebElement FindElement(LocatorType by, string locator)
        {
            // // loggerInfo.Instance.LogInfo("Find By [ " + by + " ]" + " Locator [ " + locator + " ]");
            IWebElement parentElement = null;

            return(FindElement(by, locator, 2, parentElement));//TODO: Ideally we should be using 0 but for now its 2 sec
        }
Exemplo n.º 15
0
        public static bool ClickElement(LocatorType by, string locator, bool teardownTestIfFail, string logMessage)
        {
            IWebElement element = FindElement(by, locator, string.Empty);

            if (element != null)
            {
                try
                {
                    // loggerInfo.Instance.Message(logMessage);
                    // loggerInfo.Instance.Message("Click on " + locator);
                    return(ClickElement(element, teardownTestIfFail));
                }
                catch (Exception e)
                {
                    // // loggerInfo.Instance.LogAppErro(e, "Unable to Click on Element : [ " + locator + " ]", NLog.LogLevel.Error);
                    return(false);
                }
            }
            else
            {
                Exception e = new Exception("Click Element with By [ " + by + " ]" + " Locator [ " + locator + " ]");
                // // loggerInfo.Instance.LogAppErro(e, "", NLog.LogLevel.Error);
                return(false);
            }
        }
Exemplo n.º 16
0
        public static void TypeElement(LocatorType by, string locator, string textToType, string logMessage, bool hitEnterAfterType)
        {
            string postString = string.Empty;

            if (logMessage != "")
            {
                // loggerInfo.Instance.Message(logMessage);
            }
            if (hitEnterAfterType)
            {
                postString = System.Environment.NewLine;
            }

            IWebElement element = FindElement(by, locator, string.Empty);

            try
            {
                ClickElement(element, false);
                // loggerInfo.Instance.Message("Type '" + textToType + "' in Elements with By [ " + by + " ]" + " Locator [ " + locator + " ]");
                element.SendKeys(textToType + postString);
            }
            catch (Exception e)
            {
                e = new Exception(e.Message);
                // // loggerInfo.Instance.LogAppErro(e, "Unable to Type '" + textToType + "' in Elements with By [ " + by + " ]" + " Locator [ " + locator + " ]", NLog.LogLevel.Error);
                return;
            }
        }
 /// <summary>
 /// Returns a new <see cref="ILocator"/> instance.
 /// </summary>
 /// <param name="locators">The <see cref="LocatorBaseCollection"/> instance.</param>
 /// <param name="locatorType">The <see cref="LocatorType"/>.</param>
 /// <param name="asset">The <see cref="IAsset"/> instance for the new <see cref="ILocator"/>.</param>
 /// <param name="permissions">The <see cref="AccessPermissions"/> of the <see cref="IAccessPolicy"/> associated with the new <see cref="ILocator"/>.</param>
 /// <param name="duration">The duration of the <see cref="IAccessPolicy"/> associated with the new <see cref="ILocator"/>.</param>
 /// <param name="startTime">The start time of the new <see cref="ILocator"/>.</param>
 /// <returns>A a new <see cref="ILocator"/> instance.</returns>
 public static ILocator Create(this LocatorBaseCollection locators, LocatorType locatorType, IAsset asset, AccessPermissions permissions, TimeSpan duration, DateTime? startTime)
 {
     using (Task<ILocator> task = locators.CreateAsync(locatorType, asset, permissions, duration, startTime))
     {
         return task.Result;
     }
 }
Exemplo n.º 18
0
        //public ReadOnlyCollection<SeleniumWebButton> MoveToNextMonth()
        //{
        //    return Utility.GetControlsFromWebElements(aWebElement.FindElements(By.TagName("a")), ControlType.Button, controlAccess).Cast<SeleniumWebButton>().ToList().AsReadOnly();
        //}

        public SeleniumWebControls GetCalenderHeader(string locator, LocatorType locatorType)
        {
            switch(locatorType)
            {
                case LocatorType.ClassName:
                    return (SeleniumWebControls)Utility.GetControlFromWebElement(aWebElement.FindElement(By.ClassName(locator)), ControlType.Custom, controlAccess);

                case LocatorType.Css:
                    return (SeleniumWebControls)Utility.GetControlFromWebElement(aWebElement.FindElement(By.CssSelector(locator)), ControlType.Custom, controlAccess);

                case LocatorType.Id:
                    return (SeleniumWebControls)Utility.GetControlFromWebElement(aWebElement.FindElement(By.Id(locator)), ControlType.Custom, controlAccess);

                case LocatorType.LinkText:
                    return (SeleniumWebControls)Utility.GetControlFromWebElement(aWebElement.FindElement(By.LinkText(locator)), ControlType.Custom, controlAccess);

                case LocatorType.Name:
                    return (SeleniumWebControls)Utility.GetControlFromWebElement(aWebElement.FindElement(By.Name(locator)), ControlType.Custom, controlAccess);

                case LocatorType.PartialLinkText:
                    return (SeleniumWebControls)Utility.GetControlFromWebElement(aWebElement.FindElement(By.PartialLinkText(locator)), ControlType.Custom, controlAccess);

                case LocatorType.Xpath:
                    return (SeleniumWebControls)Utility.GetControlFromWebElement(aWebElement.FindElement(By.XPath(locator)), ControlType.Custom, controlAccess);

                default:
                    return (SeleniumWebControls)Utility.GetControlFromWebElement(aWebElement.FindElement(By.TagName(locator)), ControlType.Custom, controlAccess);
                               
            }
        }
Exemplo n.º 19
0
 private static void PublishAsset(MediaClient mediaClient, IAsset asset, ContentProtection contentProtection)
 {
     if (asset.IsStreamable)
     {
         string          locatorId   = null;
         LocatorType     locatorType = LocatorType.OnDemandOrigin;
         List <ILocator> locators    = asset.Locators.Where(l => l.Type == locatorType).ToList();
         foreach (ILocator locator in locators)
         {
             if (locatorId == null)
             {
                 locatorId = locator.Id;
             }
             locator.Delete();
         }
         List <IAssetDeliveryPolicy> deliveryPolicies = asset.DeliveryPolicies.ToList();
         foreach (IAssetDeliveryPolicy deliveryPolicy in deliveryPolicies)
         {
             asset.DeliveryPolicies.Remove(deliveryPolicy);
         }
         if (contentProtection != null)
         {
             mediaClient.AddDeliveryPolicies(asset, contentProtection);
         }
         mediaClient.CreateLocator(locatorId, locatorType, asset, false);
     }
 }
Exemplo n.º 20
0
 public WebControl(Browser aBrowser, LocatorType aLocatorType, ControlType aControl)
 {
     myAccess             = new ControlAccess();
     myAccess.Browser     = aBrowser;
     myAccess.LocatorType = aLocatorType;
     myAccess.ControlType = aControl;
     myAccess.IntializeControlAccess();
 }
Exemplo n.º 21
0
        public void LocatorDetailsAreParsedCorrectlyFromBy(LocatorType locatorType, string locatorValue)
        {
            cases.TryGetValue(locatorType, out By by);

            by.GetLocatorDetail()
            .Should()
            .BeEquivalentTo((locatorType, locatorValue));
        }
Exemplo n.º 22
0
 public void IntializeControlAccess()
 {
     aBrowserType = Browser.BrowserType;
     aWebDriver   = Browser.BrowserHandle;
     aLocatorType = LocatorType;
     aLocator     = Locator;
     aControlType = ControlType;
 }
        /// <summary>
        /// Gets Locator for Asset
        /// </summary>
        /// <param name="assetId"></param>
        /// <param name="locatorType"></param>
        /// <returns></returns>
        public ILocator GetLocator(string assetId, LocatorType locatorType)
        {
            var locator = CloudMediaContext.Locators
                          .Where(l => l.AssetId == assetId && l.Type == locatorType)
                          .FirstOrDefault();

            return(locator);
        }
Exemplo n.º 24
0
        public void Read(LocatorType type, uint locatorCount, BinaryReader reader, HashManager hashManager)
        {
            LocatorType = type;
            reader.ReadDouble();

            var hasFooter          = GetHasFooter(LocatorType);
            var hasUnknownMetadata = GetHasUnknownMetadata(LocatorType);

            // Initialize fields.
            LocatorTranslations = new Vector4[locatorCount];
            LocatorRotations    = new Quaternion[locatorCount];

            if (hasFooter)
            {
                LocatorNames    = new string[locatorCount];
                LocatorDataSets = new string[locatorCount];
            }

            if (hasUnknownMetadata)
            {
                LocatorUnknown30s = new string[locatorCount];
                LocatorUnknown31s = new string[locatorCount];
                LocatorUnknown32s = new string[locatorCount];
                LocatorUnknown33s = new string[locatorCount];
            }

            // Read locators.
            for (var i = 0; i < locatorCount; i++)
            {
                LocatorTranslations[i] = new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                LocatorRotations[i]    = new Quaternion(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());

                if (!hasUnknownMetadata)
                {
                    continue;
                }

                // TODO Resolve hashes.
                LocatorUnknown30s[i] = reader.ReadUInt32().ToString();
                LocatorUnknown31s[i] = reader.ReadUInt32().ToString();
                LocatorUnknown32s[i] = reader.ReadUInt32().ToString();
                LocatorUnknown33s[i] = reader.ReadUInt32().ToString();
            }

            // Read footer.
            if (!hasFooter)
            {
                return;
            }

            for (var i = 0; i < locatorCount; i++)
            {
                // TODO Resolve hashes.
                LocatorNames[i]    = reader.ReadUInt32().ToString();
                LocatorDataSets[i] = reader.ReadUInt32().ToString();
            }
        }
Exemplo n.º 25
0
        public void SelectorConverterThrowsForIncorrectLocatorType(LocatorType locatorType)
        {
            cases.TryGetValue(locatorType, out By by);

            Action conversion = () => ByExtensions.GetEquivalentCssLocator(by.GetLocatorDetail());

            conversion.Should().ThrowExactly <ArgumentException>()
            .WithMessage($"'By's of type {locatorType} cannot be converted to use a CssSelector.");
        }
Exemplo n.º 26
0
        public ILocator GetDynamicStreamingUrl(string targetAssetID, LocatorType type, MediaContentType contentType)
        {
            IAssetFile assetFile = null;
            ILocator locator = null;
            Uri smoothUri = null;

            var daysForWhichStreamingUrlIsActive = 365;
            var outputAsset = myMediaServiceContext.Assets.Where(a => a.Id == targetAssetID).FirstOrDefault();
            var accessPolicy = myMediaServiceContext.AccessPolicies.Create(
                outputAsset.Name
                ,TimeSpan.FromDays(daysForWhichStreamingUrlIsActive)
                ,AccessPermissions.Read );
            var assetFiles = outputAsset.AssetFiles.ToList();
            switch (type)
            {
                case LocatorType.None:
                    break;
                case LocatorType.OnDemandOrigin:
                    assetFile = assetFiles.Where(f => f.Name.ToLower().EndsWith(".ism")).FirstOrDefault();
                    locator = myMediaServiceContext.Locators.CreateLocator(LocatorType.OnDemandOrigin, outputAsset, accessPolicy, DateTime.UtcNow.AddMinutes(-5));
                     switch (contentType)
	                {
                        case MediaContentType.SmoothStreaming:
                             smoothUri = new Uri(locator.Path + assetFile.Name + "/manifest");
                            break;
                        case MediaContentType.HLS:
                            smoothUri = new Uri(locator.Path + assetFile.Name + "/manifest(format=m3u8-aapl)");
                            break;
                        case MediaContentType.HDS:
                            smoothUri = new Uri(locator.Path + assetFile.Name + "/manifest(format=f4m-f4f)");
                            break;
                        case MediaContentType.DASH:
                            smoothUri = new Uri(locator.Path + assetFile.Name + "/manifest(format=mpd-time-csf)");
                            break;
                        default:
                            throw new Exception("GetDynamicStreamingUrl Error: you must chose HLS, Smooth or HDS");
                            break;
	                }
                    this.UrlForClientStreaming = smoothUri.ToString();
                 break;
                case LocatorType.Sas:
                     var mp4Files = assetFiles.Where(f => f.Name.ToLower().EndsWith(".mp4")).ToList();
                     assetFile = mp4Files.OrderBy(f => f.ContentFileSize).LastOrDefault(); //Get Largest File
                    if (assetFile != null)
                    {
                        locator = myMediaServiceContext.Locators.CreateLocator(LocatorType.Sas, outputAsset, accessPolicy, DateTime.UtcNow.AddMinutes(-5));
                        var mp4Uri = new UriBuilder(locator.Path);
                        mp4Uri.Path += "/" + assetFile.Name;
                        this.UrlForClientStreaming = mp4Uri.ToString();
                    }
                 break;
                default:
                 break;
            }
            return locator;
        }
Exemplo n.º 27
0
 public WebControl(Browser aBrowser, LocatorType aLocatorType, string aLocator, ControlType aControlType)
 {
     myControlAccess             = new ControlAccess();
     myControlAccess.Browser     = aBrowser;
     myControlAccess.LocatorType = aLocatorType;
     myControlAccess.Locator     = aLocator;
     myControlAccess.ControlType = aControlType;
     myControlAccess.IntializeControlAccess();
     //Control = myControlAccess.GetControl();
 }
Exemplo n.º 28
0
 public WebControl(Browser aBrowser,LocatorType aLocatorType,string aLocator,ControlType aControlType)
 {
     myControlAccess = new ControlAccess();
     myControlAccess.Browser = aBrowser;
     myControlAccess.LocatorType = aLocatorType;
     myControlAccess.Locator = aLocator;
     myControlAccess.ControlType = aControlType;
     myControlAccess.IntializeControlAccess();
     //Control = myControlAccess.GetControl();
 }
Exemplo n.º 29
0
        public ByData(By by)
        {
            By = by;
            (LocatorType locatorType, string locatorValue) = by.GetLocatorDetail();
            LocatorType     = locatorType;
            OriginalLocator = locatorValue;
            Func <string, string> converterFunc = LocatorType.ConvertToCssSelectorFunc();

            IsSubAtomic = converterFunc != null;
            CssLocator  = IsSubAtomic ? converterFunc(OriginalLocator) : null;
        }
Exemplo n.º 30
0
        public ILocator CreateLocator(string locatorId, LocatorType locatorType, IAsset asset, bool readWrite)
        {
            ILocator locator = asset.Locators.Where(l => l.Type == locatorType).FirstOrDefault();

            if (locator == null)
            {
                IAccessPolicy accessPolicy = GetAccessPolicy(readWrite);
                locator = _media.Locators.CreateLocator(locatorId, locatorType, asset, accessPolicy, null);
            }
            return(locator);
        }
 /// <summary>
 /// Creates the locator.
 /// </summary>
 /// <param name="locatorId">The locator identifier.
 /// Example of acceptable formats:
 /// Locator identifier prefix followed by guid - nb:lid:UUID:8b54eb99-754e-4f33-9261-2bb9866ff41f
 /// Guid - 8b54eb99-754e-4f33-9261-2bb9866ff41f
 /// </param>
 /// <param name="locatorType">Type of the locator.</param>
 /// <param name="asset">The asset.</param>
 /// <param name="accessPolicy">The access policy.</param>
 /// <param name="startTime">The start time.</param>
 /// <param name="name">The locator name</param>
 /// <returns>A locator enabling access to the specified <paramref name="asset" />.</returns>
 public ILocator CreateLocator(string locatorId, LocatorType locatorType, IAsset asset, IAccessPolicy accessPolicy, DateTime?startTime, string name = null)
 {
     try
     {
         Task <ILocator> task = this.CreateLocatorAsync(locatorId, locatorType, asset, accessPolicy, startTime, name);
         return(task.Result);
     }
     catch (AggregateException exception)
     {
         throw exception.InnerException;
     }
 }
Exemplo n.º 32
0
 protected TestBlock GetBlockDefinedByLocatorType(LocatorType rootLocatorType)
 {
     if (rootLocatorType == LocatorType.String)
     {
         return(new TestBlock("css", driver));
     }
     else
     {
         this.byLookup.TryGetValue(rootLocatorType, out By by);
         return(new TestBlock(by, driver));
     }
 }
Exemplo n.º 33
0
        /// <summary>
        /// Reads and populates data from a binary lba file.
        /// </summary>
        public void Read(BinaryReader reader, HashManager hashManager)
        {
            // Read header
            uint locatorCount = reader.ReadUInt32();

            Type = (LocatorType)reader.ReadUInt32();
            reader.ReadDouble();

            // Read locators
            bool hasFooter = false;

            for (int i = 0; i < locatorCount; i++)
            {
                switch (Type)
                {
                case LocatorType.Type0:
                    ILocator locator0 = new LocatorType0();
                    locator0.Read(reader, hashManager.StrCode32LookupTable, hashManager.OnHashIdentified);
                    Locators.Add(locator0);
                    hasFooter = locator0.HasFooter;
                    break;

                case LocatorType.Type2:
                    ILocator locator2 = new LocatorType2();
                    locator2.Read(reader, hashManager.StrCode32LookupTable, hashManager.OnHashIdentified);;
                    Locators.Add(locator2);
                    hasFooter = locator2.HasFooter;
                    break;

                case LocatorType.Type3:
                    ILocator locator3 = new LocatorType3();
                    locator3.Read(reader, hashManager.StrCode32LookupTable, hashManager.OnHashIdentified);
                    Locators.Add(locator3);
                    hasFooter = locator3.HasFooter;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            // Read footer
            if (hasFooter)
            {
                foreach (ILocator locator in Locators)
                {
                    locator.ReadFooter(reader, hashManager.StrCode32LookupTable, hashManager.PathCode32LookupTable, hashManager.OnHashIdentified);
                }
            }
        }
        //Send Text input based on locator
        public static void EnterText(IWebDriver driver, LocatorType locatortype, string elementlocator, string value)
        {
            switch (locatortype)
            {
                case LocatorType.Id: driver.FindElement(By.Id(elementlocator)).SendKeys(value); break;
                case LocatorType.Name: driver.FindElement(By.Name(elementlocator)).SendKeys(value); break;
                case LocatorType.CssSelector: driver.FindElement(By.CssSelector(elementlocator)).SendKeys(value); break;
                case LocatorType.ClassName: driver.FindElement(By.ClassName(elementlocator)).SendKeys(value); break;
                case LocatorType.XPath: driver.FindElement(By.XPath(elementlocator)).SendKeys(value); break;
                case LocatorType.PartialLinkText: driver.FindElement(By.PartialLinkText(elementlocator)).SendKeys(value); break;
                case LocatorType.TagName: driver.FindElement(By.TagName(elementlocator)).SendKeys(value); break;

            }
        }
Exemplo n.º 35
0
        public static bool WaitForElement(LocatorType by, string locator, string logMessage)
        {
            ReadOnlyCollection <IWebElement> SearchElements = FindElements(by, locator, testTimeout);

            if (SearchElements.Count > 0)
            {
                // // loggerInfo.Instance.LogInfo("Found Elements By [ " + by + " ]" + " Locator [ " + locator + " ]");
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 36
0
 internal static void PublishStream(MediaClient mediaClient, IAsset asset, ContentProtection contentProtection)
 {
     if (asset.IsStreamable || asset.AssetType == AssetType.MP4)
     {
         if (asset.Options == AssetCreationOptions.StorageEncrypted && asset.DeliveryPolicies.Count == 0)
         {
             mediaClient.AddDeliveryPolicies(asset, contentProtection);
         }
         if (asset.Locators.Count == 0)
         {
             LocatorType locatorType = LocatorType.OnDemandOrigin;
             mediaClient.CreateLocator(null, locatorType, asset, null);
         }
     }
 }
        //Method to click on a CheckBox/Button
        public static void Click(IWebDriver driver, LocatorType locatortype, string elementlocator)
        {
            switch (locatortype)
            {
                case LocatorType.Id: driver.FindElement(By.Id(elementlocator)).Click(); break;
                case LocatorType.Name: driver.FindElement(By.Name(elementlocator)).Click(); break;
                case LocatorType.CssSelector: driver.FindElement(By.CssSelector(elementlocator)).Click(); break;
                case LocatorType.ClassName: driver.FindElement(By.ClassName(elementlocator)).Click(); break;
                case LocatorType.XPath: driver.FindElement(By.XPath(elementlocator)).Click(); break;
                case LocatorType.PartialLinkText: driver.FindElement(By.PartialLinkText(elementlocator)).Click(); break;
                case LocatorType.TagName: driver.FindElement(By.TagName(elementlocator)).Click(); break;

            }
            Thread.Sleep(2000);
        }
        /// <summary>
        /// Returns a <see cref="System.Threading.Tasks.Task&lt;ILocator&gt;"/> instance for new <see cref="ILocator"/>.
        /// </summary>
        /// <param name="locators">The <see cref="LocatorBaseCollection"/> instance.</param>
        /// <param name="locatorType">The <see cref="LocatorType"/>.</param>
        /// <param name="asset">The <see cref="IAsset"/> instance for the new <see cref="ILocator"/>.</param>
        /// <param name="permissions">The <see cref="AccessPermissions"/> of the <see cref="IAccessPolicy"/> associated with the new <see cref="ILocator"/>.</param>
        /// <param name="duration">The duration of the <see cref="IAccessPolicy"/> associated with the new <see cref="ILocator"/>.</param>
        /// <param name="startTime">The start time of the new <see cref="ILocator"/>.</param>
        /// <returns>A <see cref="System.Threading.Tasks.Task&lt;ILocator&gt;"/> instance for new <see cref="ILocator"/>.</returns>
        public static async Task<ILocator> CreateAsync(this LocatorBaseCollection locators, LocatorType locatorType, IAsset asset, AccessPermissions permissions, TimeSpan duration, DateTime? startTime)
        {
            if (locators == null)
            {
                throw new ArgumentNullException("locators", "The locators collection cannot be null.");
            }

            if (asset == null)
            {
                throw new ArgumentNullException("asset", "The asset cannot be null.");
            }

            MediaContextBase context = locators.MediaContext;

            var policy = await context.AccessPolicies.CreateAsync(asset.Name, duration, permissions);

            return await locators.CreateLocatorAsync(locatorType, asset, policy, startTime);
        }
Exemplo n.º 39
0
 /// <summary />
 /// <remarks />
 public virtual void RemoveLocator(LocatorType _locator)
 {
     this.List.Remove(_locator);
 }
        protected string GetLocator(Fields ccVerifFields, LocatorType locatorType)
        {
            string locator = string.Empty;
            string baseLocator = "//*[@id='{0}{1}']{2}";
            string forType = string.Empty;
            string forField = ccVerifFields.ToString();
            InputType inputType = GetInputType(ccVerifFields);

            switch (inputType)
            {
                case InputType.Dropdown:
                    forType = "ddl";
                    break;
                case InputType.Textbox:
                    forType = "txt";
                    break;
                case InputType.Checkbox:
                    forType = "chk";
                    break;
            }

            switch (locatorType)
            {
                case LocatorType.Edit:
                    locator = string.Format(baseLocator, forType, forField, string.Empty);
                    break;
                case LocatorType.Label:
                    if (inputType == InputType.Checkbox)
                        locator = string.Format(baseLocator, forType, forField, "/../label");

                    else
                        locator = string.Format(baseLocator, forType, forField, "/../../td[1]");
                    break;
            }

            return locator;
        }
Exemplo n.º 41
0
        private async Task<WamsLocatorInfo> CreateLocatorAsync(IAsset asset, string accessPolicyName, LocatorType type, TimeSpan duration) {
            IAccessPolicy accessPolicy = null;
            ILocator locator = null;

            try {
                accessPolicy = await Context.AccessPolicies.CreateAsync(accessPolicyName, duration, AccessPermissions.Read | AccessPermissions.List).ConfigureAwait(continueOnCapturedContext: false);
                locator = await Context.Locators.CreateLocatorAsync(type, asset, accessPolicy).ConfigureAwait(continueOnCapturedContext: false);

                Logger.Information("New {0} locator with duration {1} was created for asset '{2}'", type, duration, asset.Name);

                return new WamsLocatorInfo(locator.Id, locator.Path);
            }
            catch (Exception ex) {
                Logger.Error(ex, "Error while creating locator for asset '{0}'. Cleaning up any created locator and access policy.", asset.Name);

                try {
                    if (locator != null)
                        locator.Delete();
                    if (accessPolicy != null)
                        accessPolicy.Delete();
                }
                catch (Exception iex) {
                    Logger.Warning(iex, "Error while cleaning up created locator and access policy.");
                }

                throw;
            }
        }
Exemplo n.º 42
0
        /// <summary>
        /// Zoom to candidate depends on locator type.
        /// </summary>
        /// <param name="mapCtrl">Map control.</param>
        /// <param name="addressCandidate">Candidate to zoom.</param>
        /// <param name="locatorType">Type of locator, which return this candidate.</param>
        private static void _ZoomToCandidate(MapControl mapCtrl, AddressCandidate addressCandidate, LocatorType locatorType)
        {
            Debug.Assert(mapCtrl != null);
            Debug.Assert(addressCandidate != null);

            double extentInc = 0;

            // Get extent size.
            switch (locatorType)
            {
                case LocatorType.CityState:
                    {
                        extentInc = ZOOM_ON_CITY_STATE_CANDIDATE;
                        break;
                    }
                case LocatorType.Zip:
                    {
                        extentInc = ZOOM_ON_ZIP_CANDIDATE;
                        break;
                    }
                case LocatorType.Street:
                    {
                        extentInc = ZOOM_ON_STREET_CANDIDATE;
                        break;
                    }
                default:
                    {
                        Debug.Assert(false);
                        break;
                    }
            }

            // Make extent rectangle.
            ESRI.ArcLogistics.Geometry.Envelope rect = new ESRI.ArcLogistics.Geometry.Envelope();
            rect.SetEmpty();
            rect.Union(addressCandidate.GeoLocation);

            rect.left -= extentInc;
            rect.right += extentInc;
            rect.top += extentInc;
            rect.bottom -= extentInc;

            ESRI.ArcGIS.Client.Geometry.Envelope extent = GeometryHelper.CreateExtent(rect,
                mapCtrl.Map.SpatialReferenceID);
            mapCtrl.ZoomTo(extent);
        }
Exemplo n.º 43
0
        public PublishStatus GetPublishedStatus(LocatorType LocType)
        {
            PublishStatus LocPubStatus;

            // if there is one locato for this type
            if ((SelectedAssets.FirstOrDefault().Locators.Where(l => l.Type == LocType).Count() > 0))
            {
                if (!SelectedAssets.FirstOrDefault().Locators.Where(l => (l.Type == LocType)).All(l => (l.ExpirationDateTime < DateTime.UtcNow)))
                {// not all int the past
                    var query = SelectedAssets.FirstOrDefault().Locators.Where(l => ((l.Type == LocType) && (l.ExpirationDateTime > DateTime.UtcNow) && (l.StartTime != null)));
                    // if no locator are valid today but at least one will in the future
                    if (query.ToList().Count() > 0)
                    {
                        LocPubStatus = (query.All(l => (l.StartTime > DateTime.UtcNow))) ? PublishStatus.PublishedFuture : PublishStatus.PublishedActive;
                    }
                    else
                    {
                        LocPubStatus = PublishStatus.PublishedActive;
                    }
                }
                else      // if all locators are in the past
                {
                    LocPubStatus = PublishStatus.PublishedExpired;
                }
            }
            else
            {
                LocPubStatus = PublishStatus.NotPublished;
            }
            return LocPubStatus;
        }
Exemplo n.º 44
0
        internal static List<IControl> GetChildren(string Locator, LocatorType aLocatorType, ControlType aControlType, IWebElement aWebElement, ControlAccess access)
        {
            if (aLocatorType == LocatorType.Id)
            {
                return Utility.GetControlsFromWebElements(aWebElement.FindElements(By.Id(Locator)), aControlType, access);
            }

            if (aLocatorType == LocatorType.Name)
            {
                return Utility.GetControlsFromWebElements(aWebElement.FindElements(By.Name(Locator)), aControlType, access);
            }

            if (aLocatorType == LocatorType.TagName)
            {
                return Utility.GetControlsFromWebElements(aWebElement.FindElements(By.TagName(Locator)), aControlType, access);
            }

            if (aLocatorType == LocatorType.Xpath)
            {
                return Utility.GetControlsFromWebElements(aWebElement.FindElements(By.XPath(Locator)), aControlType, access);
            }

            if (aLocatorType == LocatorType.ClassName)
            {
                return Utility.GetControlsFromWebElements(aWebElement.FindElements(By.ClassName(Locator)), aControlType, access);
            }

            if (aLocatorType == LocatorType.Css)
            {
                return Utility.GetControlsFromWebElements(aWebElement.FindElements(By.CssSelector(Locator)), aControlType, access);
            }

            if (aLocatorType == LocatorType.LinkText)
            {
                return Utility.GetControlsFromWebElements(aWebElement.FindElements(By.LinkText(Locator)), aControlType, access);
            }

            if (aLocatorType == LocatorType.PartialLinkText)
            {
                return Utility.GetControlsFromWebElements(aWebElement.FindElements(By.PartialLinkText(Locator)), aControlType, access);
            }

            else return null;
        }
 /// <summary>
 /// Returns a new <see cref="ILocator"/> instance.
 /// </summary>
 /// <param name="locators">The <see cref="LocatorBaseCollection"/> instance.</param>
 /// <param name="locatorType">The <see cref="LocatorType"/>.</param>
 /// <param name="asset">The <see cref="IAsset"/> instance for the new <see cref="ILocator"/>.</param>
 /// <param name="permissions">The <see cref="AccessPermissions"/> of the <see cref="IAccessPolicy"/> associated with the new <see cref="ILocator"/>.</param>
 /// <param name="duration">The duration of the <see cref="IAccessPolicy"/> associated with the new <see cref="ILocator"/>.</param>
 /// <returns>A a new <see cref="ILocator"/> instance.</returns>
 public static ILocator Create(this LocatorBaseCollection locators, LocatorType locatorType, IAsset asset, AccessPermissions permissions, TimeSpan duration)
 {
     return locators.Create(locatorType, asset, permissions, duration, null);
 }
Exemplo n.º 46
0
 /// <summary />
 /// <remarks />
 public virtual bool ContainsLocator(LocatorType _locator)
 {
     return this.List.Contains(_locator);
 }
Exemplo n.º 47
0
 /// <summary />
 /// <remarks />
 public virtual void AddLocator(LocatorType _locator)
 {
     this.List.Add(_locator);
 }
Exemplo n.º 48
0
        public LinkedTextLocator(IFolder folder)
            : this((ISymbolLocator)folder)
        {
            if (folder == null)
                throw new ArgumentNullException("folder");

            this.folder = folder;
            this.type = LocatorType.Folder;
        }
Exemplo n.º 49
0
        public SeleniumWebControls GetMonthAndYear(string locator, LocatorType locatorType, string headerLocator, LocatorType headerLocatorType)
        {

            return (SeleniumWebControls)Utility.GetControlFromWebElement(GetCalenderHeader(headerLocator, headerLocatorType).aWebElement.FindElement(By.ClassName(locator)), ControlType.Custom, controlAccess);
        }
        private void ProcessCreateLocator(LocatorType locatorType, List<IAsset> assets, AccessPermissions accessPolicyPermissions, TimeSpan accessPolicyDuration, Nullable<DateTime> startTime, string ForceLocatorGUID)
        {
            IAccessPolicy policy;
            try
            {
                policy = _context.AccessPolicies.Create("AP AMSE", accessPolicyDuration, accessPolicyPermissions);
            }
            catch (Exception ex)
            {
                TextBoxLogWriteLine("Error. Could not create access policy.", true);
                TextBoxLogWriteLine(ex);
                return;
            }

            foreach (var AssetToP in assets)
            {
                ILocator locator = null;

                try
                {
                    if (locatorType == LocatorType.Sas || string.IsNullOrEmpty(ForceLocatorGUID)) // It's a SAS loctor or user does not want to force the GUID if this is a Streaming locator
                    {
                        locator = _context.Locators.CreateLocator(locatorType, AssetToP, policy, startTime);
                    }
                    else // Streaming locator and user wants to force the GUID
                    {
                        locator = _context.Locators.CreateLocator(ForceLocatorGUID, LocatorType.OnDemandOrigin, AssetToP, policy, startTime);
                    }
                }
                catch (Exception ex)
                {
                    TextBoxLogWriteLine("Error. Could not create a locator for '{0}' (is the asset encrypted, or locators quota has been reached ?)", AssetToP.Name, true);
                    TextBoxLogWriteLine(ex);
                    return;
                }
                if (locator == null) return;

                // let's choose a SE that running and with higher number of RU
                IStreamingEndpoint SESelected = AssetInfo.GetBestStreamingEndpoint(_context);
                bool SESelectedHasRU = SESelected.ScaleUnits > 0;

                if (!SESelectedHasRU && AssetToP.AssetType != AssetType.SmoothStreaming)
                {
                    TextBoxLogWriteLine("There is no running streaming endpoint with a scale unit.", true);
                }

                StringBuilder sbuilderThisAsset = new StringBuilder();
                sbuilderThisAsset.AppendLine("Asset:");
                sbuilderThisAsset.AppendLine(AssetToP.Name);
                sbuilderThisAsset.AppendLine("Locator ID:");
                sbuilderThisAsset.AppendLine(locator.Id);
                sbuilderThisAsset.AppendLine("Locator Path (best streaming endpoint selected)");
                sbuilderThisAsset.AppendLine(AssetInfo.RW(locator.Path, SESelected));
                sbuilderThisAsset.AppendLine("");

                if (locatorType == LocatorType.OnDemandOrigin)
                {
                    // Get the MPEG-DASH URL of the asset for adaptive streaming.
                    Uri mpegDashUri = AssetInfo.RW(locator.GetMpegDashUri(), SESelected);

                    // Get the HLS URL of the asset for adaptive streaming.
                    Uri HLSUri = AssetInfo.RW(locator.GetHlsUri(), SESelected);
                    Uri HLSUriv3 = AssetInfo.RW(locator.GetHlsv3Uri(), SESelected);

                    // Get the Smooth URL of the asset for adaptive streaming.
                    Uri SmoothUri = AssetInfo.RW(locator.GetSmoothStreamingUri(), SESelected);

                    if (AssetToP.AssetType == AssetType.MediaServicesHLS)
                    // It is a static HLS asset, so let's propose only the standard HLS V3 locator
                    {
                        sbuilderThisAsset.AppendLine(AssetInfo._hls_v3 + " : ");
                        sbuilderThisAsset.AppendLine(AddBracket(HLSUriv3.AbsoluteUri));
                    }
                    else // It's not Static HLS
                    {
                        if (!SESelectedHasRU && AssetToP.AssetType == AssetType.SmoothStreaming)
                        // it's smooth streaming with no dynamic packaging
                        {
                            sbuilderThisAsset.AppendLine(AssetInfo._smooth + " : ");
                            sbuilderThisAsset.AppendLine(AddBracket(SmoothUri.AbsoluteUri));
                        }
                        else if (SESelectedHasRU && (AssetToP.AssetType == AssetType.SmoothStreaming || AssetToP.AssetType == AssetType.MultiBitrateMP4))
                        // Smooth or multi MP4, SE RU so dynamic packaging is possible
                        {
                            if (locator.GetSmoothStreamingUri() != null)
                            {
                                sbuilderThisAsset.AppendLine(AssetInfo._smooth + " : ");
                                sbuilderThisAsset.AppendLine(AddBracket(SmoothUri.AbsoluteUri));
                                sbuilderThisAsset.AppendLine(AssetInfo._smooth_legacy + " : ");
                                sbuilderThisAsset.AppendLine(AddBracket(AssetInfo.GetSmoothLegacy(SmoothUri.AbsoluteUri)));
                            }
                            if (locator.GetMpegDashUri() != null)
                            {
                                sbuilderThisAsset.AppendLine(AssetInfo._dash + " : ");
                                sbuilderThisAsset.AppendLine(AddBracket(mpegDashUri.AbsoluteUri));
                            }
                            if (locator.GetHlsUri() != null)
                            {
                                sbuilderThisAsset.AppendLine(AssetInfo._hls_v4 + " : ");
                                sbuilderThisAsset.AppendLine(AddBracket(HLSUri.AbsoluteUri));
                                sbuilderThisAsset.AppendLine(AssetInfo._hls_v3 + " : ");
                                sbuilderThisAsset.AppendLine(AddBracket(AssetInfo.RW(locator.GetHlsv3Uri(), SESelected).AbsoluteUri));
                            }
                        }
                    }
                }
                else //SAS
                {
                    IEnumerable<IAssetFile> AssetFiles = AssetToP.AssetFiles.ToList();

                    // Generate the Progressive Download URLs for each file. 
                    List<Uri> ProgressiveDownloadUris =
                        AssetFiles.Select(af => af.GetSasUri()).ToList();


                    TextBoxLogWriteLine("You can progressively download the following files :");
                    ProgressiveDownloadUris.ForEach(uri =>
                    {
                        sbuilderThisAsset.AppendLine(AddBracket(uri.AbsoluteUri));
                    }
                                        );
                }
                //log window
                TextBoxLogWriteLine(sbuilderThisAsset.ToString());

                if (sbuilderThisAsset != null)
                {
                    sbuilder.Append(sbuilderThisAsset); // we add this builder to the general builder
                                                        // COPY to clipboard. We need to create a STA thread for it
                    System.Threading.Thread MyThread = new Thread(new ParameterizedThreadStart(DoCopyClipboard));
                    MyThread.SetApartmentState(ApartmentState.STA);
                    MyThread.IsBackground = true;
                    MyThread.Start(sbuilder.ToString());
                }
            }
            dataGridViewAssetsV.PurgeCacheAssets(assets);
            dataGridViewAssetsV.AnalyzeItemsInBackground();
        }
Exemplo n.º 51
0
        internal static By GetByFromLocator(LocatorType locatorType, string locator)
        {
            switch (locatorType)
            {
                case LocatorType.ClassName:
                    return By.ClassName(locator);

                case LocatorType.Css:
                    return By.CssSelector(locator);

                case LocatorType.Id:
                    return By.Id(locator);

                case LocatorType.LinkText:
                    return By.LinkText(locator);

                case LocatorType.Name:
                    return By.Name(locator);

                case LocatorType.PartialLinkText:
                    return By.PartialLinkText(locator);

                case LocatorType.TagName:
                    return By.TagName(locator);

                case LocatorType.Xpath:
                    return By.XPath(locator);

                default:
                    return By.XPath(locator);
            }
        }
        private bool IsThereALocatorValid(IAsset asset, ref ILocator locator, LocatorType mylocatortype = LocatorType.OnDemandOrigin)
        {
            bool valid = false;
            if (asset != null && asset.Locators.Count > 0)
            {
                ILocator LocatorQuery = asset.Locators.Where(l => (l.Type == mylocatortype) && ((l.StartTime < DateTime.UtcNow) || (l.StartTime == null)) && (l.ExpirationDateTime > DateTime.UtcNow)).FirstOrDefault();
                if (LocatorQuery != null)
                {
                    //OK we can play the content
                    locator = LocatorQuery;
                    valid = true;
                }

            }
            return valid;
        }
Exemplo n.º 53
0
 public Locator(string Locator, LocatorType LocatorType)
 {
     ControlLocator = Locator;
     this.LocatorType = LocatorType;
 }
Exemplo n.º 54
0
 public List<IControl> GetChildren(string Locator, LocatorType aLocatorType, ControlType aControlType)
 {
     return Utility.GetChildren(Locator, aLocatorType, aControlType,aWebElement,this);                        
 } 
Exemplo n.º 55
0
 public void IntializeControlAccess()
 {
     aBrowserType = Browser.BrowserType;
     aWebDriver = Browser.BrowserHandle;
     aLocatorType = LocatorType;
     aLocator = Locator;
     aControlType = ControlType;            
 }
Exemplo n.º 56
0
        public LinkedTextLocator(ITranslator translator)
            : this((ISymbolLocator)translator)
        {
            if (translator == null)
                throw new ArgumentNullException("translator");

            this.translator = translator;
            this.type = LocatorType.Translator;
        }
Exemplo n.º 57
0
 //Select Top Menu Item
 public static void SelectLeftMenuItem(IWebDriver driver, LocatorType menuLocatorType, string menulocator, LocatorType menuitemLocatorType, string menuitemLocator)
 {
     ControlAccessMethods.Click(driver, menuLocatorType, menulocator);
     ControlAccessMethods.Click(driver, menuitemLocatorType, menuitemLocator);
 }
Exemplo n.º 58
0
        public LinkedTextLocator(IDelimiter delimiter)
            : this((ITextLocator)delimiter)
        {
            if (delimiter == null)
                throw new ArgumentNullException("delimiter");

            this.delimiter = delimiter;
            this.type = LocatorType.Delimiter;
        }
        //Method to select value in a drop down control
        public static void SelectDropDown(IWebDriver driver, LocatorType locatortype, string elementlocator, string value)
        {
            switch (locatortype)
            {
                case LocatorType.Id: new SelectElement(driver.FindElement(By.Id(elementlocator))).SelectByText(value); break;
                case LocatorType.Name: new SelectElement(driver.FindElement(By.Name(elementlocator))).SelectByText(value); break;
                case LocatorType.CssSelector: new SelectElement(driver.FindElement(By.CssSelector(elementlocator))).SelectByText(value); break;
                case LocatorType.ClassName: new SelectElement(driver.FindElement(By.ClassName(elementlocator))).SelectByText(value); break;
                case LocatorType.XPath: new SelectElement(driver.FindElement(By.XPath(elementlocator))).SelectByText(value); break;
                case LocatorType.PartialLinkText: new SelectElement(driver.FindElement(By.PartialLinkText(elementlocator))).SelectByText(value); break;
                case LocatorType.TagName: new SelectElement(driver.FindElement(By.TagName(elementlocator))).SelectByText(value); break;

            }
        }
Exemplo n.º 60
0
 //Enter Text in search textbox
 public static void Search(IWebDriver driver, string searchterm, LocatorType locatortype, string searchtextboxlocator)
 {
     ControlAccessMethods.EnterText(driver, locatortype, searchtextboxlocator, searchterm);
 }