private AssetData CreateAssetFromWebElementFindFromElement(IWebElement assetWE) { AssetData asset = new AssetData(); //get from Web Element only the number and then search the rest of the elements by id IWebElement assetNbr = assetWE.FindElement(By.XPath("//p[contains(@id,'assetNumber')]")); asset.Id = assetNbr.GetAttribute("id").Replace("assetNumber", ""); //top region asset.Number = assetNbr.Text; asset.Name = assetWE.FindElement(By.Id(String.Format(assetNameByIdTemplate, asset.Id))).Text; try { IWebElement cornerTagWE = assetWE.FindElement(By.Id(String.Format(assetCornerTagByIdTemplate, asset.Id))); asset.CornerTagColor = this.GetColorFromColorCode(cornerTagWE.FindElement(By.TagName("polygon")).GetCssValue("fill")); asset.CornerTagText = cornerTagWE.FindElement(By.TagName("text")).Text; } catch (Exception) { asset.CornerTagColor = ""; asset.CornerTagText = ""; } try { IWebElement faDateWE = assetWE.FindElement(By.Id(String.Format(assetFaDateByIdTemplate, asset.Id))); asset.FADate = faDateWE.Text; asset.FADateLabel = assetWE.FindElement(By.Id(String.Format(assetFaDateLabelByIdTemplate, asset.Id))).Text; asset.FADateColor = this.GetColorFromColorCode(faDateWE.GetCssValue("color")); } catch (Exception) { asset.FADate = ""; asset.FADateColor = ""; asset.FADateLabel = ""; } asset.Type = assetWE.FindElement(By.Id(String.Format(assetTypeByIdTemplate, asset.Id))).Text; asset.ValueType = assetWE.FindElement(By.Id(String.Format(assetValueTypeByIdTemplate, asset.Id))).Text; //left asset.CodeLabel = assetWE.FindElement(By.Id(String.Format(assetCodeLabelByIdTemplate, asset.Id))).Text; try { asset.Code = assetWE.FindElement(By.Id(String.Format(assetCodeByIdTemplate, asset.Id))).Text; } catch (Exception) { asset.Code = ""; } //center asset.PetitionPosition = assetWE.FindElement(By.Id(String.Format(assetPetitionPositionByIdTemplate, asset.Id))).Text; asset.PetitionLabel = assetWE.FindElement(By.Id(String.Format(assetPetitionLabelByIdTemplate, asset.Id))).Text; asset.Petition = assetWE.FindElement(By.Id(String.Format(assetPetitionByIdTemplate, asset.Id))).Text; asset.NetValuePosition = assetWE.FindElement(By.Id(String.Format(assetNetValuePositionByIdTemplate, asset.Id))).Text; asset.NetValueLabel = assetWE.FindElement(By.Id(String.Format(assetNetValueLabelByIdTemplate, asset.Id))).Text; asset.NetValue = assetWE.FindElement(By.Id(String.Format(assetNetvalueByIdTemplate, asset.Id))).Text; asset.AbandonedPosition = assetWE.FindElement(By.Id(String.Format(assetAbandonedPositionByIdTemplate, asset.Id))).Text; asset.AbandonedLabel = assetWE.FindElement(By.Id(String.Format(assetAbandonedLabelByIdTemplate, asset.Id))).Text; asset.Abandoned = assetWE.FindElement(By.Id(String.Format(assetAbandonedByIdTemplate, asset.Id))).Text; asset.SalesPosition = assetWE.FindElement(By.Id(String.Format(assetSalesPositionByIdTemplate, asset.Id))).Text; asset.SalesLabel = assetWE.FindElement(By.Id(String.Format(assetSalesLabelByIdTemplate, asset.Id))).Text; asset.Sales = assetWE.FindElement(By.Id(String.Format(assetSalesByIdTemplate, asset.Id))).Text; asset.RemainingPosition = assetWE.FindElement(By.Id(String.Format(assetRemainingPositionByIdTemplate, asset.Id))).Text; asset.RemainingLabel = assetWE.FindElement(By.Id(String.Format(assetRemainingLabelByIdTemplate, asset.Id))).Text; asset.Remaining = assetWE.FindElement(By.Id(String.Format(assetRemainingByIdTemplate, asset.Id))).Text; asset.TrusteeLabel = assetWE.FindElement(By.Id(String.Format(assetTrusteeLabelByIdTemplate, asset.Id))).Text; asset.Trustee = assetWE.FindElement(By.Id(String.Format(assetTrusteeByIdTemplate, asset.Id))).Text; asset.LiensLabel = assetWE.FindElement(By.Id(String.Format(assetLiensLabelByIdTemplate, asset.Id))).Text; asset.Liens = assetWE.FindElement(By.Id(String.Format(assetLiensByIdTemplate, asset.Id))).Text; asset.ExemptionsLabel = assetWE.FindElement(By.Id(String.Format(assetExemptionsLabelByIdTemplate, asset.Id))).Text; asset.Exemptions = assetWE.FindElement(By.Id(String.Format(assetExemptionsByIdTemplate, asset.Id))).Text; //bottom region asset.Form1NoteLabel = assetWE.FindElement(By.Id(String.Format(assetForm1NoteLabelByIdTemplate, asset.Id))).Text; asset.Form1Note = assetWE.FindElement(By.Id(String.Format(assetForm1NoteByIdTemplate, asset.Id))).Text; return(asset); }
private AssetData CreateAssetFromWebElement(IWebElement assetWE) { AssetData asset = new AssetData(); //get from Web Element only the number and then search the rest of the elements by id IWebElement assetNbr = assetWE.FindElement(By.XPath(".//p[contains(@id,'assetNumber')]")); asset.Id = assetNbr.GetAttribute("id").Replace("assetNumber", ""); //top region asset.Number = assetNbr.Text; asset.Name = this.WaitForElementToBeVisible(By.Id(String.Format(assetNameByIdTemplate, asset.Id))).Text; try { IWebElement cornerTagWE = this.WaitForElementToBeVisible(By.Id(String.Format(assetCornerTagByIdTemplate, asset.Id)), 2); asset.CornerTagColor = this.GetColorFromColorCode(cornerTagWE.FindElement(By.TagName("polygon")).GetCssValue("fill")); asset.CornerTagText = cornerTagWE.FindElement(By.TagName("text")).Text; } catch (Exception) { asset.CornerTagColor = ""; asset.CornerTagText = ""; } try { IWebElement faDateWE = this.WaitForElementToBeVisible(By.Id(String.Format(assetFaDateByIdTemplate, asset.Id)), 2); asset.FADate = faDateWE.Text; asset.FADateLabel = this.WaitForElementToBeVisible(By.Id(String.Format(assetFaDateLabelByIdTemplate, asset.Id))).Text; asset.FADateColor = this.GetColorFromColorCode(faDateWE.GetCssValue("color")); } catch (Exception) { asset.FADate = ""; asset.FADateColor = ""; asset.FADateLabel = ""; } asset.Type = this.WaitForElementToBeVisible(By.Id(String.Format(assetTypeByIdTemplate, asset.Id))).Text; asset.ValueType = this.WaitForElementToBeVisible(By.Id(String.Format(assetValueTypeByIdTemplate, asset.Id))).Text; //left asset.CodeLabel = this.WaitForElementToBeVisible(By.Id(String.Format(assetCodeLabelByIdTemplate, asset.Id))).Text; try { asset.Code = this.WaitForElementToBeVisible(By.Id(String.Format(assetCodeByIdTemplate, asset.Id)), 2).Text; } catch (Exception) { asset.Code = ""; } //center asset.PetitionPosition = this.WaitForElementToBeVisible(By.Id(String.Format(assetPetitionPositionByIdTemplate, asset.Id))).Text; asset.PetitionLabel = this.WaitForElementToBeVisible(By.Id(String.Format(assetPetitionLabelByIdTemplate, asset.Id))).Text; asset.Petition = this.WaitForElementToBeVisible(By.Id(String.Format(assetPetitionByIdTemplate, asset.Id))).Text; asset.NetValuePosition = this.WaitForElementToBeVisible(By.Id(String.Format(assetNetValuePositionByIdTemplate, asset.Id))).Text; asset.NetValueLabel = this.WaitForElementToBeVisible(By.Id(String.Format(assetNetValueLabelByIdTemplate, asset.Id))).Text; asset.NetValue = this.WaitForElementToBeVisible(By.Id(String.Format(assetNetvalueByIdTemplate, asset.Id))).Text; asset.AbandonedPosition = this.WaitForElementToBeVisible(By.Id(String.Format(assetAbandonedPositionByIdTemplate, asset.Id))).Text; asset.AbandonedLabel = this.WaitForElementToBeVisible(By.Id(String.Format(assetAbandonedLabelByIdTemplate, asset.Id))).Text; asset.Abandoned = this.WaitForElementToBeVisible(By.Id(String.Format(assetAbandonedByIdTemplate, asset.Id))).Text; asset.SalesPosition = this.WaitForElementToBeVisible(By.Id(String.Format(assetSalesPositionByIdTemplate, asset.Id))).Text; asset.SalesLabel = this.WaitForElementToBeVisible(By.Id(String.Format(assetSalesLabelByIdTemplate, asset.Id))).Text; asset.Sales = this.WaitForElementToBeVisible(By.Id(String.Format(assetSalesByIdTemplate, asset.Id))).Text; asset.RemainingPosition = this.WaitForElementToBeVisible(By.Id(String.Format(assetRemainingPositionByIdTemplate, asset.Id))).Text; asset.RemainingLabel = this.WaitForElementToBeVisible(By.Id(String.Format(assetRemainingLabelByIdTemplate, asset.Id))).Text; asset.Remaining = this.WaitForElementToBeVisible(By.Id(String.Format(assetRemainingByIdTemplate, asset.Id))).Text; asset.TrusteeLabel = this.WaitForElementToBeVisible(By.Id(String.Format(assetTrusteeLabelByIdTemplate, asset.Id))).Text; asset.Trustee = this.WaitForElementToBeVisible(By.Id(String.Format(assetTrusteeByIdTemplate, asset.Id))).Text; asset.LiensLabel = this.WaitForElementToBeVisible(By.Id(String.Format(assetLiensLabelByIdTemplate, asset.Id))).Text; asset.Liens = this.WaitForElementToBeVisible(By.Id(String.Format(assetLiensByIdTemplate, asset.Id))).Text; asset.ExemptionsLabel = this.WaitForElementToBeVisible(By.Id(String.Format(assetExemptionsLabelByIdTemplate, asset.Id))).Text; asset.Exemptions = this.WaitForElementToBeVisible(By.Id(String.Format(assetExemptionsByIdTemplate, asset.Id))).Text; //bottom region asset.Form1NoteLabel = this.WaitForElementToBeVisible(By.Id(String.Format(assetForm1NoteLabelByIdTemplate, asset.Id))).Text; IWebElement form1Note = this.WaitForElementToBePresent(By.Id(String.Format(assetForm1NoteByIdTemplate, asset.Id))); //text can only ve invisble when empty, otherwise text is not displaying correctly and something is wrong if ((!form1Note.Displayed && form1Note.Text == "") || (form1Note.Displayed && form1Note.Text != "")) { asset.Form1Note = form1Note.Text; } else { asset.Form1Note = null; } return(asset); }