public override void OnCreate() { var hT = new HierarchyTransform(Position, Rotation, null); foreach (var seRef in SceneDef.Entities) { Locators.Add(new LocToId() { Id = CurrentServer.AcquireId(), Loc = seRef.Def }); } foreach (var seRef in Locators) { var spawnedEntitySceneDef = seRef.Loc; var spawnedEntityDef = EntityObjectsMap.GetDefFromSceneDef(spawnedEntitySceneDef); var scenePos = (Vec2)spawnedEntitySceneDef.GetType().GetProperty(nameof(IPositionedEntity.Position)).GetValue(spawnedEntitySceneDef); var sceneRot = (float)spawnedEntitySceneDef.GetType().GetProperty(nameof(IPositionedEntity.Rotation)).GetValue(spawnedEntitySceneDef); var objItemDef = spawnedEntitySceneDef.GetType().GetProperty(nameof(WorldItemEntity.StartingItemDef)); var itemDef = objItemDef == null ? null : ((DefRef <ItemDef>)objItemDef.GetValue(spawnedEntitySceneDef)).Def; var lT = new HierarchyTransform(scenePos, sceneRot, hT); CurrentServer.Create(seRef.Id, EntityObjectsMap.GetTypeFromDef(spawnedEntityDef), e => { ((IEntityObject)e).Def = (IEntityObjectDef)(((ISceneDef)spawnedEntitySceneDef).Object.Def); ((IPositionedEntity)e).Position = lT.GlobalPos; ((IPositionedEntity)e).Rotation = lT.GlobalRot; if (e is WorldItemEntity wie) { wie.StartingItemDef = itemDef; } }); } }
private void buttonListAnimation_Click(object sender, EventArgs e) { AnimatedDecoration listAnimation = new AnimatedDecoration(this.olvSimple); Animation animation = listAnimation.Animation; //Sprite image = new ImageSprite(Resource1.largestar); //image.FixedLocation = Locators.SpriteAligned(Corner.MiddleCenter); //image.Add(0, 2000, Effects.Rotate(0, 360 * 2f)); //image.Add(1000, 1000, Effects.Fade(1.0f, 0.0f)); //animation.Add(0, image); Sprite image = new ImageSprite(Resource1.largestar); image.Add(0, 500, Effects.Move(Corner.BottomCenter, Corner.MiddleCenter)); image.Add(0, 500, Effects.Rotate(0, 180)); image.Add(500, 1500, Effects.Rotate(180, 360 * 2.5f)); image.Add(500, 1000, Effects.Scale(1.0f, 3.0f)); image.Add(500, 1000, Effects.Goto(Corner.MiddleCenter)); image.Add(1000, 900, Effects.Fade(1.0f, 0.0f)); animation.Add(0, image); Sprite text = new TextSprite("Animations!", new Font("Tahoma", 32), Color.Blue, Color.AliceBlue, Color.Red, 3.0f); text.Opacity = 0.0f; text.FixedLocation = Locators.SpriteAligned(Corner.MiddleCenter); text.Add(900, 900, Effects.Fade(0.0f, 1.0f)); text.Add(1000, 800, Effects.Rotate(180, 1440)); text.Add(2000, 500, Effects.Scale(1.0f, 0.5f)); text.Add(3500, 1000, Effects.Scale(0.5f, 3.0f)); text.Add(3500, 1000, Effects.Fade(1.0f, 0.0f)); animation.Add(0, text); animation.Start(); }
public void GujaratiShaadiRegisteration() { Locators locate = new Locators(); GetFile("GujaratiRegisterationData.json"); driver.Navigate().GoToUrl("https://www.gujaratishaadi.com/"); RegisterationFlow(locate); }
public static IWebElement PerformActionOn(this IWebDriver browser, Locators.By.jQueryBy by, Action<IWebElement> actionToPerform) { var element = browser.FindElementByjQuery(@by); actionToPerform(element); return element; }
public IEnumerable<IWebElement> Elements(Locators.By.jQueryBy jQueryFindExpression, TimeSpan maxWait = new TimeSpan()) { var atLeastOneElement = OptionalElement(jQueryFindExpression, maxWait); if (atLeastOneElement == null) return Enumerable.Empty<IWebElement>(); return Browser.FindElements(jQueryFindExpression); }
private void AddStarAnimation(Animation animation, int start, float opacity) { Sprite sprite = new ImageSprite(Resource1.star32); sprite.Opacity = opacity; sprite.Add(0, 4000, Effects.Walk(Locators.AnimationBounds(), WalkDirection.Anticlockwise)); sprite.Add(0, 4000, Effects.Rotate(0, 1480)); animation.Add(start, sprite); }
public void Register(Locator locator) { Locators.Add(locator); if (Started) { locator.SetupIndicators(Locatables); } }
public void MarathiShaadiRegisteration() { //Negative Test, change the email in json to run sucessfully Locators locate = new Locators(); GetFile("MarathiRegisterationData.json"); driver.Navigate().GoToUrl("https://www.marathishaadi.com/"); RegisterationFlow(locate); }
public bool IsExecutionTabShown(string runName) { string fullRunTitleValue = GetExecutionTabFullTitleValue(runName); WebElement executionFrame = mainPage.GetElement().ByXPath(Locators.runFrameXPath(fullRunTitleValue)); string currentExecutionFrameClassValue = executionFrame.GetAttribute(WEBUIautomation.Tags.TagAttributes.Class); return(currentExecutionFrameClassValue == Locators.shownTabFrameClassValue); }
public bool IsDltShown(string testName) { string fullTitleValue = GetDltTabFullTitleValue(testName); WebElement dltFrame = mainPage.GetElement().ByXPath(Locators.dltIFrameXPath(fullTitleValue)); string currentDltFrameClassValue = dltFrame.GetAttribute(WEBUIautomation.Tags.TagAttributes.Class); return(currentDltFrameClassValue == Locators.shownTabFrameClassValue); }
public IWebElement OptionalElement(Locators.By.jQueryBy jQueryFindExpression, TimeSpan maxWait = default(TimeSpan)) { try { return Element(jQueryFindExpression, maxWait); } catch (NoSuchElementException) { return null; } }
public IWebElement TryFindElementByjQuery(Locators.By.jQueryBy @by) { IWebElement result = null; try { result = Browser.FindElementByjQuery(@by); } catch (NoSuchElementException) { } return result; }
/// <summary> /// This method writes to the dictionary models of machines and their number /// </summary> /// <returns></returns> public Dictionary <string, int> ListCars() { Locators locators = new Locators(); modelAndNumberOfCars = new Dictionary <string, int>(); WebDriverWait waiter = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); foreach (IWebElement oneModel in waiter.Until(driver => driver.FindElements(By.XPath(locators.Model)))) { modelAndNumberOfCars.Add((oneModel.FindElement(By.TagName("span")).Text), int.Parse(oneModel.FindElement(By.TagName("small")).Text)); } return(modelAndNumberOfCars); }
public IWebElement LocateElement(Locators type, string name) { return(type switch { Locators.Xpath => Driver.FindElement(By.XPath(name)), Locators.CssSelector => Driver.FindElement(By.CssSelector(name)), Locators.ID => Driver.FindElement(By.Id(name)), Locators.Name => Driver.FindElement(By.Name(name)), Locators.LinkText => Driver.FindElement(By.LinkText(name)), Locators.ClassName => Driver.FindElement(By.ClassName(name)), Locators.PartialLinkText => Driver.FindElement(By.PartialLinkText(name)), Locators.TagName => Driver.FindElement(By.TagName(name)), _ => throw new ArgumentOutOfRangeException(type.ToString(), $"Invalid Type, {type.ToString()}") });
void Execute(Action <IWebElement> seleniumCode, IWebDriver driver) { foreach (var locator in Locators) { int staleRetryCount = 3; for (int i = 0; i < staleRetryCount; i++) { try { IWebElement targetElement = driver.FindElement(By.XPath(locator)); seleniumCode.Invoke(targetElement); break; } catch (WebDriverException ex) { if (ex is NoSuchElementException) { if (locator == Locators.Last()) { throw; } } else if (ex is StaleElementReferenceException) { continue; } else if (ex is ElementClickInterceptedException) { if (ex.Message.Contains("helpdesk-notification-popup")) { new WebItem("//div[contains(@class, 'popup-close-btn')]", "Кнопка закрытия баннера").Click(driver); continue; } else { throw; } } else { throw; } } break; } } }
/// <summary> /// Used to dispose of resources in use by the <see cref="AdminViewModel{TViewModel, TModel, TModelSearcher}"/> /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { if (!_disposedValue) { if (disposing) { ApplicationRestrictor.RequestUnlock(_adminToken); FamilialLocker.RequestUnlock(_adminToken); CriticalOperationType = CriticalOperationType.None; if (ModelSearcher != null) { ModelSearcher.SelectedItems.CollectionChanged -= SelectedItems_CollectionChanged; ModelSearcher.ExportId -= ModelSearcher_ExportId; ModelSearcher.Cleared -= ModelSearcher_Cleared; ModelSearcher.RequestEnable(_adminToken); } Model.ErrorsChanged -= Model_ErrorsChanged; Model.Dispose(); _newEnableCallback = null; _duplicateEnableCallback = null; _modifyEnableCallback = null; _backEnableCallback = null; _forwardEnableCallback = null; _performDeleteOnRecordEnableCallback = null; _backForwardNavigator.CurrentItemChangedCallback = null; _backForwardNavigator?.Dispose(); Navigation.Dispose(); RecordChangeLocker.Dispose(); ConfirmCancelLocker.Dispose(); NewRecordCancelLocker.Dispose(); NavigationalOverride.Dispose(); OutsideModificationLocker.Dispose(); DefaultModelCallback = null; Locators.ForEach(locator => { locator.SearchToBegin -= Locator_SearchToBegin; locator.SearchComplete -= Locator_SearchComplete; locator.RecordRequested -= Locator_RecordRequested; locator.RequestEnable(_adminToken); }); Locators.Clear(); } _disposedValue = true; } base.Dispose(disposing); }
/// <summary> /// The logic used whenever a dependent locator is swapped. /// </summary> /// <param name="newLocator">The new locator.</param> /// <param name="oldLocator">The old locator.</param> /// <param name="token">The token to use to lock.</param> protected void ProcessLocatorSwap(ILocator newLocator, ILocator oldLocator, object token) { if (oldLocator != null) { Locators.Remove(oldLocator); oldLocator.SearchToBegin -= Locator_SearchToBegin; oldLocator.SearchComplete -= Locator_SearchComplete; oldLocator.RecordRequested -= Locator_RecordRequested; } if (newLocator != null) { Locators.Add(newLocator); newLocator.RequestClear(); newLocator.RequestDisable(token); newLocator.SearchToBegin += Locator_SearchToBegin; newLocator.SearchComplete += Locator_SearchComplete; newLocator.RecordRequested += Locator_RecordRequested; } }
/// <summary> /// The logic used to update the <see cref="ModelSearcher" />. /// </summary> /// <param name="searcher">The new <see cref="ModelSearcher" />.</param> /// <returns>Task for async use.</returns> public async Task UpdateModelSearcher(IVMLocator <TModelSearcher> searcher) { var oldValue = _modelSearcher; if (Perform.ReplaceIfDifferent(ref _modelSearcher, searcher).WasSuccessful) { if (oldValue != null) { Locators.Remove(oldValue); oldValue.SelectedItems.CollectionChanged -= SelectedItems_CollectionChanged; oldValue.ExportId -= ModelSearcher_ExportId; oldValue.Cleared -= ModelSearcher_Cleared; } if (_modelSearcher != null) { _modelSearcher.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged; _modelSearcher.ExportId += ModelSearcher_ExportId; _modelSearcher.Cleared += ModelSearcher_Cleared; Locators.Add(_modelSearcher); if (_modelSearcher.CurrentItems.Any()) { var navCollection = (_modelSearcher.SelectedItems.Take(2).Count() == 2 ? _modelSearcher.SelectedItems : _modelSearcher.CurrentItems ); _backForwardNavigator.UpdateNavigationCollection(navCollection.Select(item => item.Id)); int currentItem = (_modelSearcher.SelectedItems.Any() ? _modelSearcher.SelectedItems : _modelSearcher.CurrentItems ).First().Id; await _backForwardNavigator.UpdateCurrentItem(currentItem); } } await OnModelSearcherSwapped(oldValue); OnPropertyChanged(nameof(ModelSearcher)); } }
private void buttonCellAnimation_Click(object sender, EventArgs e) { object modelObject = this.olvSimple.GetModelObject(Math.Min(5, this.olvSimple.GetItemCount())); if (modelObject == null || this.olvSimple.Columns.Count < 2) { Coordinator.ShowMessage("There aren't any cells to be animated"); return; } AnimatedDecoration animatedDecoration = new AnimatedDecoration(this.olvSimple, modelObject, this.olvSimple.GetColumn(1)); Animation animation = animatedDecoration.Animation; ShapeSprite sprite = ShapeSprite.RoundedRectangle(5.0f, Color.Firebrick, Color.FromArgb(48, Color.Firebrick)); sprite.Opacity = 0.0f; sprite.CornerRounding = 14; sprite.FixedBounds = Locators.AnimationBounds(3, 3); sprite.Add(0, 4500, Effects.Blink(3)); animation.Add(0, sprite); animation.Start(); }
//void FilterOutWrongLocators() //{ // // TODO: test with Selenium // Locators.ForEach(locator => // { // // if () outside the screen // }); //} internal string GenerateCodeEntryWithBestLocator() { if (!Locators.Any()) { return(string.Empty); } var bestLocator = Locators.First(locator => locator.IsBestChoice); var result = string.Empty; if (SupportedTargetLanguages.Java == _targetLanguage) { result = $"\r\n@{bestLocator.Attribute}({bestLocator.ElementSearchTypePreference}=\"{bestLocator.SearchString}\")"; } if (SupportedTargetLanguages.CSharp == _targetLanguage) { result = $"\r\n[{bestLocator.Attribute}({bestLocator.ElementSearchTypePreference}=\"{bestLocator.SearchString}\")]"; } /* * @JDropdown(root = @FindBy(css = "dropdown"), value = @FindBy(id = "dropdownMenu1"), list = @FindBy(tagName = "li")) * IDropDown<JobCategories> category; */ if (JdiMemberType.IsComplexControl()) { result += GenerateAnnotationForComplexType(_targetLanguage); } var overallResult = string.Empty; if (SupportedTargetLanguages.Java == _targetLanguage || SupportedTargetLanguages.CSharp == _targetLanguage) { overallResult = string.IsNullOrEmpty(result) ? result : $"{result}\r\npublic {JdiMemberType.ConvertToTypeString(EnumerationTypeName)} {MemberName};"; } return(overallResult); }
public override CommandNode DeepClone(GameObject dataHolder) { CNJet clone = CNJet.CreateInstance <CNJet>(dataHolder); clone.field_ = Field.DeepClone(); clone.locators_ = Locators.DeepClone(); clone.Name = Name; clone.Timer = Timer; clone.force_ = Force; clone.speedLimit_ = SpeedLimit; clone.forceDeltaMax_ = forceDeltaMax_; clone.angleDeltaMax_ = angleDeltaMax_; clone.periodTime_ = periodTime_; clone.periodSpace_ = periodSpace_; clone.highFrequency_am_ = highFrequency_am_; clone.highFrequency_sp_ = highFrequency_sp_; return(clone); }
protected override void CloneData(CommandNode node) { base.CloneData(node); CNJet clone = (CNJet)node; clone.field_ = Field.DeepClone(); clone.locators_ = Locators.DeepClone(); clone.Name = Name; clone.Timer = Timer; clone.force_ = Force; clone.speedLimit_ = SpeedLimit; clone.forceDeltaMax_ = forceDeltaMax_; clone.angleDeltaMax_ = angleDeltaMax_; clone.periodTime_ = periodTime_; clone.periodSpace_ = periodSpace_; clone.highFrequency_am_ = highFrequency_am_; clone.highFrequency_sp_ = highFrequency_sp_; }
public IWebElement TryFindElementByjQuery(Locators.By.jQueryBy @by) { throw new NotImplementedException("Obsolete"); }
//Not clicking on signup button to avoid creating fake signups public void RegisterationFlow(Locators locate) { string error_text = ""; try { click(locate.lnk_login); click(locate.lnk_signup); enter_text(locate.txt_email, GetJsonData("Email")); enter_text(locate.txt_passwd, GetJsonData("Password")); click(locate.dd_createprofile); clickDropdownValue(locate.dd_createprofilelist, GetJsonData("Profile")); if (GetJsonData("Profile").Equals("Self") || GetJsonData("Profile").Equals("Friend") || GetJsonData("Profile").Equals("Relative")) { if (GetJsonData("Gender").Equals("Female")) { click(locate.rad_gender_female); } else { click(locate.rad_gender_male); } } click(locate.btn_next); if (isElementPresent(locate.email_error)) { error_text = driver.FindElement(locate.email_error).Text; throw new Exception(); } if (isElementPresent(locate.passwd_error)) { error_text = driver.FindElement(locate.passwd_error).Text; throw new Exception(); } enter_text(locate.txt_first_name, GetJsonData("Firstname")); enter_text(locate.txt_last_name, GetJsonData("Lastname")); click(locate.dd_dobday); clickDropdownValue(locate.dd_daylist, GetJsonData("BirthDay")); click(locate.dd_dobmonth); clickDropdownValue(locate.dd_monthlist, GetJsonData("BirthMonth")); click(locate.dd_dobyear); clickDropdownValue(locate.dd_yearlist, GetJsonData("BirthYear")); click(locate.dd_religion); clickDropdownValue(locate.dd_religionlist, GetJsonData("Religion")); Assert.AreEqual(locate.dd_mothertongue_defaulted.Text, GetJsonData("MotherTongue")); click(locate.dd_country); clickDropdownValue(locate.dd_countrylist, GetJsonData("Country")); //click(locate.btn_signup); Dispose(); } catch (Exception e) { if (error_text == "") { Dispose(); throw new Exception(e.Message); } else { Dispose(); throw new Exception(error_text); } } }
public IWebElement Element(Locators.By.jQueryBy jQueryFindExpression, TimeSpan maxWait = default(TimeSpan)) { return Browser.ElementWithWait(d => d.FindElementByjQuery(jQueryFindExpression), maxWait); }
static NewPayLoad GeneratePlatformActionPayload(IActPluginExecution ACT, Agent agent) { PlatformAction platformAction = ACT.GetAsPlatformAction(); if (ACT is ActUIElement actUi) { if (actUi.LocateBy == eLocateBy.POMElement) { AddPOMLocators(ref platformAction, ref actUi, agent.ProjEnvironment, agent.BusinessFlow); } } // TODO: calculate VE ??!! NewPayLoad payload = new NewPayLoad("RunPlatformAction"); payload.AddJSONValue <PlatformAction>(platformAction); payload.ClosePackage(); // TODO: Process Valuefordriver!!!! return(payload); void AddPOMLocators(ref PlatformAction PlatformAction, ref ActUIElement UIElementAction, ProjEnvironment projEnvironment, BusinessFlow businessFlow) { Dictionary <string, string> Locators = null; if (PlatformAction.InputParams.ContainsKey("Locators")) { Locators = (Dictionary <string, string>)PlatformAction.InputParams["Locators"]; } else { Locators = new Dictionary <string, string>(); } List <string> Frames = new List <string>(); string[] pOMandElementGUIDs = UIElementAction.ElementLocateValue.ToString().Split('_'); Guid selectedPOMGUID = new Guid(pOMandElementGUIDs[0]); ApplicationPOMModel currentPOM = amdocs.ginger.GingerCoreNET.WorkSpace.Instance.SolutionRepository.GetRepositoryItemByGuid <ApplicationPOMModel>(selectedPOMGUID); if (currentPOM == null) { UIElementAction.ExInfo = string.Format("Failed to find the mapped element Page Objects Model with GUID '{0}'", selectedPOMGUID.ToString()); return; } Guid selectedPOMElementGUID = new Guid(pOMandElementGUIDs[1]); ElementInfo selectedPOMElement = (ElementInfo)currentPOM.MappedUIElements.Where(z => z.Guid == selectedPOMElementGUID).FirstOrDefault(); if (selectedPOMElement == null) { UIElementAction.ExInfo = string.Format("Failed to find the mapped element with GUID '{0}' inside the Page Objects Model", selectedPOMElement.ToString()); return; } else { List <NewPayLoad> switchframpayload = new List <NewPayLoad>(); if (selectedPOMElement.Path != null) { string[] spliter = new string[] { "," }; string[] iframesPathes = selectedPOMElement.Path.Split(spliter, StringSplitOptions.RemoveEmptyEntries); foreach (string iframePath in iframesPathes) { Frames.Add(iframePath); } } //adding all locators from POM foreach (ElementLocator locator in selectedPOMElement.Locators.Where(x => x.Active == true).ToList()) { string locateValue; if (locator.IsAutoLearned) { locateValue = locator.LocateValue; } else { ElementLocator evaluatedLocator = locator.CreateInstance() as ElementLocator; GingerCore.ValueExpression VE = new GingerCore.ValueExpression(projEnvironment, businessFlow); locateValue = VE.Calculate(evaluatedLocator.LocateValue); } Locators.Add(locator.LocateBy.ToString(), locateValue); } } } }
public IElementAssert ConformTo(Locators.By.jQueryBy findExpression, Action<IEnumerable<IWebElement>> assertion, TimeSpan maxWait = default(TimeSpan)) { return ConformTo(() => { var elements = Find.Elements(findExpression, maxWait); assertion(elements); }); }
public CommonElement(string locator, Locators type) { Locator = locator; LocatorType = type; }
public IElementAssert Exist(Locators.By.jQueryBy findExpression, string message = null, TimeSpan maxWait = default(TimeSpan)) { return Exist(() => Find.Element(findExpression, maxWait), message); }
public void AddLocator <T>() where T : IViewLocator { Locators.Add(typeof(T)); }
public Build ByBuildLocator(Locators.BuildLocator locator) { return _caller.GetFormat<Build>(string.Format("/app/rest/builds/{0}", locator)); }