public Element FindElement(string key, FindTypes type) { try { switch (type) { case (FindTypes.Id): return(new Element(WebDriver.Driver.FindElement(By.Id(key)), key, type)); case (FindTypes.Xpath): return(new Element(WebDriver.Driver.FindElement(By.XPath(key)), key, type)); case (FindTypes.ClassName): return(new Element(WebDriver.Driver.FindElement(By.ClassName(key)), key, type)); case (FindTypes.Css): return(new Element(WebDriver.Driver.FindElement(By.CssSelector(key)), key, type)); } } catch (NoSuchElementException) { return(new Element(key, type)); } return(null); }
public void Create() { var expectedProperties = new List <string> { "PutAnotherPropertyStringLength = 123", "PutPropertyRangeMin = 33", "PutPropertyRangeMax = 66", "PutPropertyIsRequired = true", "PutPropertyIsCreditCard = true", "GetSomePropertyIsRequired = true", "GetSomePropertyMinLength = 55", "PostCollectionOfNestedTypesIsRequired = true", "PostSomePropertyIsRequired = true", "TestNestedPropertyStringLength = 123", "TestNestedTypeInCollectionPropertyIsRequired = true", "PostSomePropertyRegularExpression = `^[a-z''-'\\s]{1,3}$`", "TestNestedTypeInCollectionPropertyRegularExpression = ``", "TestAnotherNestedTypeInCollectionPropertyMaxLength = 22", }; var expectedClasses = new List <string> { "TypeFinderTestsTestApiTestGetRequest", "TypeFinderTestsTestApiTestPostRequest", "TypeFinderTestsTestApiTestPutRequest", "TypeFinderTestsTestApiTestNestedType", "TypeFinderTestsTestApiTestNestedTypeInCollection", "TypeFinderTestsTestApiNamespaceWithDuplicatedNamesTestNestedType" }; var ts = TsDefinitions.CreateFor(AttributesTranform.For(FindTypes.Find("TypeFinder.Tests.dll"), TsFromAttribute.For)); expectedProperties.ForEach(c => Assert.IsTrue(ts.Contains(c))); expectedClasses.ForEach(c => Assert.IsTrue(ts.Contains($"export class {c}"))); }
public void Create() { var expectedProperties = new List <string> { "static readonly PutAnotherPropertyValidators = [Validators.minLength(123), Validators.maxLength(123)];", "static readonly PutPropertyValidators = [Validators.min(33), Validators.max(66), Validators.required];", "static readonly GetSomePropertyValidators = [Validators.required, Validators.minLength(55)];", "static readonly PostCollectionOfNestedTypesValidators = [Validators.required];", "static readonly PostSomePropertyValidators = [Validators.required, Validators.pattern(`^[a-z''-'\\s]{1,3}$`)];", "static readonly TestNestedPropertyValidators = [Validators.minLength(123), Validators.maxLength(123)];", "static readonly TestAnotherNestedTypeInCollectionPropertyValidators = [Validators.required, Validators.maxLength(22)];", "static readonly TestEmailNestedTypeInCollectionPropertyValidators = [Validators.email];", "static readonly TestNestedTypeInCollectionPropertyValidators = [Validators.required, Validators.pattern(``)];" }; var expectedClasses = new List <string> { "TypeFinderTestsTestApiTestGetRequest", "TypeFinderTestsTestApiTestPostRequest", "TypeFinderTestsTestApiTestPutRequest", "TypeFinderTestsTestApiTestNestedType", "TypeFinderTestsTestApiTestNestedTypeInCollection", "TypeFinderTestsTestApiNamespaceWithDuplicatedNamesTestNestedType" }; var ts = NgReactiveFormValidators.CreateFor( AttributesTranform.For(FindTypes.Find("TypeFinder.Tests.dll"), NgValidatorsFromAttribute.For)); expectedProperties.ForEach(c => Assert.IsTrue(ts.Contains(c))); expectedClasses.ForEach(c => Assert.IsTrue(ts.Contains($"export class {c}Validators"))); }
public Element(IWebElement e, string q, FindTypes t) { WebElement = e; Query = q; IsDisplayed = WebElement.Displayed; IsSelected = WebElement.Selected; Text = WebElement.GetAttribute("value"); Type = t; RetryCount = Convert.ToInt32(ConfigurationManager.AppSettings["RetryCount"]); }
public static void Generate(string assemblyFilePath, string tsConstantsDestination, string ngReactiveFormValidatorsDestination) { var types = FindTypes.Find(assemblyFilePath); if (!string.IsNullOrWhiteSpace(tsConstantsDestination)) { System.IO.File.WriteAllText(tsConstantsDestination, TsDefinitions.CreateFor(AttributesTranform.For(types, TsFromAttribute.For))); } if (!string.IsNullOrWhiteSpace(ngReactiveFormValidatorsDestination)) { System.IO.File.WriteAllText( ngReactiveFormValidatorsDestination, NgReactiveFormValidators.CreateFor(AttributesTranform.For(types, NgValidatorsFromAttribute.For))); } }
public FinderResult Find(FindTypes findTypes) { var results = GetResults(); if (results.Count < 1) { return(new FinderResult()); } var sortedResults = results.OrderBy(result => result.TimeSpan).ToList(); var resultWithShortestTimeSpan = sortedResults[0]; var resultWithLongestTimeSpan = sortedResults[sortedResults.Count - 1]; return(findTypes == FindTypes.ClosestTwo ? resultWithShortestTimeSpan : resultWithLongestTimeSpan); }
static Vector3D getDesiredTyeBlockCenter(FindTypes findType) { Rectangle res = new Rectangle(); if (findType == FindTypes.Max) res = getMaxCountBlock(); else res = getMinCountBlock(); if (res.X == 0 && res.Y == 0) { return null; } if (res.X >= 0 && res.Y >= 0) { return new Vector3D(res.X + (int)res.Width / 2, res.Y + (int)res.Width / 2, 0); } return null; }
public static Vector3D FindMobBlock(ref List<D3Object> liveMobs, FindTypes findType) { Vector3D res = null; if (liveMobs != null && liveMobs.Count > 0) { initSurroundingBlocks(D3Control.Player.Location); foreach (var mob in liveMobs) { addMonsterLoc(mob.Location); } //var preTime = DateTime.Now; res = getDesiredTyeBlockCenter(findType); //D3Control.output("time", string.Format("Time52 {0}", DateTime.Now.Subtract(preTime).TotalMilliseconds)); } return res; }
public static Vector3D FindMobBlock(ref List<D3Object> liveMobs, FindTypes findType, out D3Object TargetMob) { Vector3D res = null; TargetMob = null; if (liveMobs != null && liveMobs.Count > 0) { initSurroundingBlocks(D3Control.Player.Location); foreach (var mob in liveMobs) { addMonsterLoc(mob.Location); } //var preTime = DateTime.Now; res = getDesiredTyeBlockCenter(findType); if (res != null) { foreach (var mob in liveMobs) { var mobLoc = mob.Location; if (D3Control.isObjectValid(mob) && mobLoc.GetDistanceTo(res, true) < 12) { res = mobLoc; TargetMob = mob; break; } } } //D3Control.output("time", string.Format("Time52 {0}", DateTime.Now.Subtract(preTime).TotalMilliseconds)); } return res; }
// ******************************************************************************** /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <returns></returns> /// <created>UPh,19.11.2015</created> /// <changed>UPh,19.11.2015</changed> // ******************************************************************************** private void btnFindText_Click(object sender, EventArgs e) { FindType = FindTypes.Text; DoFind(); }
// ******************************************************************************** /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <returns></returns> /// <created>UPh,19.11.2015</created> /// <changed>UPh,19.11.2015</changed> // ******************************************************************************** private void btnFindTerm_Click(object sender, EventArgs e) { FindType = FindTypes.Terminology; DoFind(); }
public static Vector3D FindMobBlock(ref List<D3Object> liveMobs, FindTypes findType) { Vector3D res = null; if (liveMobs != null && liveMobs.Count > 0) { initSurroundingBlocks(D3Control.Player.Location); foreach (var mob in liveMobs) { addMonsterLoc(mob.Location); } res = getDesiredTyeBlockCenter(findType); } return res; }
public Element(string q, FindTypes t) { Query = q; Type = t; }