public void SelectDropDown(String locator, String targetValue) { this.WaitForElementPresent(locator, 20); Assert.IsTrue(isElementPresent(locator)); IWebElement dropDownListBox = driver.FindElement(ByLocator(locator)); SelectElement clickThis = new SelectElement(dropDownListBox); clickThis.SelectByValue(targetValue); }
private void button1_Click(object sender, EventArgs e) { var smsPvaService = new SMSPVA(); var userInfo = smsPvaService.GetUserInfo(); var countriesOrderByPriceDesc = smsPvaService.GetChepeastCountrySMSReceive(); var lowestPriceCountries = countriesOrderByPriceDesc.Where(x => x.price <= Convert.ToDecimal(0.20)).ToList(); while (userInfo.balance >= lowestPriceCountries.Last().price) { var r = new Random(); var y = r.Next(0, lowestPriceCountries.Count); var lowestPriceRandomCountry = lowestPriceCountries.ElementAt(y); var lowestPriceCountry = lowestPriceRandomCountry; ChromeDriver driver = null; Process process = null; try { var _profileGenerator = new ProfilerGenerator(); var pessoa = _profileGenerator.Generate(); MongoConnection _mongoConnection = new MongoConnection(); ProcessStartInfo info = new ProcessStartInfo() { CreateNoWindow = true, FileName = @"C:\Users\Peterson Andrade\source\repos\InstaAccCreator_netframework\bin\x64\Debug\InstaAccCreator_netframework.exe", Arguments = pessoa.Proxy.username + ":" + pessoa.Proxy.password + "@" + pessoa.Proxy.proxy_address + ":" + pessoa.Proxy.ports.http.ToString() }; process = Process.Start(info); CountryCodes countryCodes = new CountryCodes(); var countryCodeDetails = countryCodes.AllCountries.Where(x => x.isoCode2digits == lowestPriceCountry.country).First(); var numberObject = smsPvaService.GetNumber(lowestPriceCountry.country); numberObject.number = "+" + countryCodeDetails.countryCode + numberObject.number; //var getSms = smsPvaService.GetSms(lowestPriceCountry.country, numberObject.id); pessoa.Number = numberObject; var options = new ChromeOptions(); //options.BinaryLocation = @"C:\Users\Peterson Andrade\source\repos\InstaAccCreator_netframework\bin\x64\Debug\InstaAccCreator_netframework.exe"; //options.AddArgument("url=data:,"); //options.AddArgument("no-sandbox"); //options.AddArgument("--headless"); //options options.DebuggerAddress = "localhost:8081"; //var driverService = ChromeDriverService.CreateDefaultService(); //driverService.HideCommandPromptWindow = true; options.PageLoadStrategy = PageLoadStrategy.Normal; var driverService = ChromeDriverService.CreateDefaultService(); driverService.HideCommandPromptWindow = true; driver = new ChromeDriver(driverService, options); driver.Navigate().GoToUrl("https://instagram.com"); //driver.Navigate().GoToUrl("http://google.com"); //AppDomain.CurrentDomain.ProcessExit += new EventHandler((x, y) => //{ // driver.Close(); // process.Kill(); //}); var search_Locator = By.TagName("a"); var wait = new WebDriverWait(driver, new System.TimeSpan(0, 1, 0)); wait.Until(ExpectedConditions.ElementIsVisible(search_Locator)); //System.Threading.Thread.Sleep(10000); bool IsVisibleSignUpLink = false; do { var elements = driver.FindElements(search_Locator);//.Where(x => x.GetAttribute("href") == "//"); foreach (var element in elements) { var elementHreftext = (element.GetProperty("href")); if (elementHreftext.Contains("accounts/emailsignup")) { //MessageBox.Show("Found!"); IsVisibleSignUpLink = true; element.Click(); } this.richTextBox1.AppendText(elementHreftext + "\n"); } } while (!IsVisibleSignUpLink); var email_Locator = By.Name("emailOrPhone"); wait.Until(ExpectedConditions.ElementIsVisible(email_Locator)); var emailElement = driver.FindElement(email_Locator); emailElement.Click(); //emailElement.SendKeys("+5521987655678"); emailElement.SendKeys(numberObject.number); //emailElement.FindElement(By.ClassName("coreSpriteInputAccepted")); //emailElement.FindElement(By.ClassName("coreSpriteInputError")); //emailElement.FindElement(By.ClassName("coreSpriteInputRefresh")); var fullName_Locator = By.Name("fullName"); wait.Until(ExpectedConditions.ElementIsVisible(fullName_Locator)); var fullNameElement = driver.FindElement(fullName_Locator); fullNameElement.Click(); fullNameElement.SendKeys(pessoa.Nome); var userName_Locator = By.Name("username"); wait.Until(ExpectedConditions.ElementIsVisible(userName_Locator)); var userNameElement = driver.FindElement(userName_Locator); userNameElement.Click(); userNameElement.SendKeys(pessoa.UserName); var password_Locator = By.Name("password"); wait.Until(ExpectedConditions.ElementIsVisible(password_Locator)); var passwordElement = driver.FindElement(password_Locator); passwordElement.Click(); passwordElement.SendKeys(pessoa.Senha); userNameElement = driver.FindElement(userName_Locator); IWebElement userNameDivElement = userNameElement.FindElement(By.XPath("..")).FindElement(By.XPath("..")); try { var acceptedLocator = By.ClassName("coreSpriteInputAccepted"); wait.Until(ExpectedConditions.ElementIsVisible(acceptedLocator)); var userNameInputAcceptedElement = userNameDivElement.FindElement(acceptedLocator); if (!userNameInputAcceptedElement.Displayed) { } } catch (Exception ex) { try { var errorLocator = By.ClassName("coreSpriteInputError"); wait.Until(ExpectedConditions.ElementIsVisible(errorLocator)); var userNameInputErrorElement = userNameDivElement.FindElement(errorLocator); if (userNameInputErrorElement.Displayed) { var refreshLocator = By.ClassName("coreSpriteInputRefresh"); wait.Until(ExpectedConditions.ElementIsVisible(refreshLocator)); var userNameInputRefreshElement = userNameDivElement.FindElement(By.ClassName("coreSpriteInputRefresh")); userNameInputRefreshElement.Click(); passwordElement.Click(); userNameElement = driver.FindElement(userName_Locator); pessoa.UserName = userNameElement.GetProperty("value"); } } catch (Exception exc) { } } var signUpButton_Locator = By.TagName("button"); wait.Until(ExpectedConditions.ElementIsVisible(signUpButton_Locator)); var elementsBtn = driver.FindElements(signUpButton_Locator);//.Where(x => x.GetAttribute("href") == "//"); foreach (var element in elementsBtn) { var elementHreftext = (element.GetProperty("type")); if (elementHreftext.Contains("submit")) { //new Actions(driver).MoveToElement(element).Perform(); //MessageBox.Show("Found!"); element.Click(); } } //Verificar a presença do Sprite de Aniversário var birthDayClass = By.ClassName("glyphsSpriteBirthday_cake"); wait.Until(ExpectedConditions.ElementIsVisible(birthDayClass)); var selectElementLocator = By.TagName("select"); wait.Until(ExpectedConditions.ElementIsVisible(selectElementLocator)); var selectElement = driver.FindElements(selectElementLocator);//.Where(x => x.GetAttribute("href") == "//"); //MessageBox.Show("Quantidade de Selects = " + selectElement.Count.ToString()); //select 0 = mês //select 1 = dia //select 2 = ano //select 3 = idioma var selectMes = new SelectElement(selectElement[0]); selectMes.SelectByValue(pessoa.DataNascimento.Month.ToString()); var selectDia = new SelectElement(selectElement[1]); selectDia.SelectByValue(pessoa.DataNascimento.Day.ToString()); var selectAno = new SelectElement(selectElement[2]); selectAno.SelectByValue(pessoa.DataNascimento.Year.ToString()); var buttonLocator = By.TagName("Button"); wait.Until(ExpectedConditions.ElementIsVisible(buttonLocator)); var buttonElement = driver.FindElements(buttonLocator); //foreach (var element in buttonElement) //{ // this.richTextBox1.AppendText("button Type=:" + element.GetProperty("type")); // this.richTextBox1.AppendText(element.Text + "\n"); //} buttonElement[1].Click(); //Verificar a presença do Sprite de Confirmação var phoneSpriteConfirmationClass = By.ClassName("glyphsSpritePhone_confirm"); wait.Until(ExpectedConditions.ElementIsVisible(phoneSpriteConfirmationClass)); //TryGet SMS var getSms = smsPvaService.GetSms(lowestPriceCountry.country, numberObject.id); int i = 0; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); while (getSms.sms == null) { getSms = smsPvaService.GetSms(lowestPriceCountry.country, numberObject.id); System.Threading.Thread.Sleep(20000); i += 20000; if (stopwatch.ElapsedMilliseconds >= TimeSpan.FromMinutes(10).TotalMilliseconds) { //TODO: ban Number var retornoBan = smsPvaService.BanNumber(numberObject.id); break; } } //Confirmation Code Input var confirmCodeInputLocator = By.Name("confirmationCode"); wait.Until(ExpectedConditions.ElementIsVisible(confirmCodeInputLocator)); var confirmationCodeInputElement = driver.FindElement(confirmCodeInputLocator); //confirmationCodeInputElement.SendKeys("9829384"); confirmationCodeInputElement.SendKeys(getSms.sms); //Click The Button //Wich button ? buttonLocator = By.TagName("Button"); wait.Until(ExpectedConditions.ElementIsVisible(buttonLocator)); buttonElement = driver.FindElements(buttonLocator); buttonElement[0].Click(); //0-button text: Confirm //1-button text: Change Number //2-button text: Request New Code //Esperar aparecer o SearchBar var searchBarIconClass = By.ClassName("coreSpriteSearchIcon"); wait.Until(ExpectedConditions.ElementIsVisible(searchBarIconClass)); //foreach (var element in buttonElement) //{ // //this.richTextBox1.AppendText("button Type=:" + element.GetProperty("type")); // this.richTextBox1.AppendText("button text::" + element.Text); // this.richTextBox1.AppendText(element.Text + "\n"); //} richTextBox1.ScrollToCaret(); //0 - Why Do we need birthday //1 - next //2 - back //foreach (var element in selectElement) //{ // var select = new SelectElement(element); // var elementHreftext = (element.GetProperty("title")); // this.richTextBox1.AppendText(elementHreftext + "\n"); // foreach (var option in select.Options) // { // var valuefromOption = option.GetProperty("value"); // this.richTextBox1.AppendText(valuefromOption + "\n"); // } // // selectElelemt.Options.ToList().ForEach(x => { // // x.GetProperty("value") // //var elementHreftext = (element.GetProperty("type")); // // if (elementHreftext.Contains("submit")) //} _mongoConnection.Pessoas.InsertOne(pessoa); } catch (Exception ex) { } finally { try { if (driver != null) { driver.Close(); } if (process != null) { process.Kill(); } } catch (Exception exc) { } finally { userInfo = smsPvaService.GetUserInfo(); } } } }
public void SelectElementFromList(WebElement element, string option) { Builder.MoveToElement(element.WrappedElement).Click(); Select = new SelectElement(element.WrappedElement); Select.SelectByValue(option); }
public void SelectUnitedKingdomFromCountry() { SelectElement select = new SelectElement(country); select.SelectByValue("GB"); }
public void SelectSystemDevice() { SelectElement element = new SelectElement(lstSystemDropdownList); element.SelectByValue("25"); }
static void Main(string[] args) { IWebDriver driver = new ChromeDriver(); try { //Launch google developers webpage driver.Url = "https://developers.google.com/"; Console.WriteLine("Opened Chrome Browser to https://developers.google.com/..."); // Confirm text description for Google Cloud Next '18 string googleCloudNextDescr = "Hone your skills on the latest cloud technologies with Google experts at hundreds of breakout sessions and interactive on-demand hands-on labs and bootcamps. You'll have the opportunity to engage with the best minds in cloud technology on how your industry is adapting, innovating, and growing with cloud."; string getEventDescrText = driver.FindElement(By.ClassName("devsite-landing-row-item-description-content")).Text; if (getEventDescrText.Contains(googleCloudNextDescr)) { Console.WriteLine("Google Cloud Next '18 event description confirmed..."); } else { Console.WriteLine("Could not find description for Google Cloud Next '18. Closing browser."); driver.Close(); } // Click on the Google Cloud Next '18 event driver.FindElement(By.Id("google-cloud-next-18br-july-24-26-san-francisco-usa")).Click(); Console.WriteLine("Navigated to the Google Cloud Next '18 event page..."); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30); // Confirm that the first H3 on the page is "Imagine" var h3Tag = driver.FindElement(By.XPath("//h3[text() = 'Imagine']")).Text; if (h3Tag == "Imagine") { Console.WriteLine("Confirmed H3 tag \"Imagine\"..."); } else { Console.WriteLine("Could not find H3 tag \"Imagine\". Closing browser."); driver.Close(); } // Click "Get updates" button var getUpdatesButton = driver.FindElement(By.XPath("//button[contains(text(), 'Get updates')]")); getUpdatesButton.Click(); Console.WriteLine("Clicked on \"Get updates\" button..."); // Send keys for input fields Console.WriteLine("Sending keys..."); driver.FindElement(By.Id("firstName")).SendKeys("Zach"); driver.FindElement(By.Id("lastName")).SendKeys("Phillips"); driver.FindElement(By.Id("email")).SendKeys("*****@*****.**"); driver.FindElement(By.Id("jobTitle")).SendKeys("Developer"); driver.FindElement(By.Id("company")).SendKeys("My Company"); var industry = driver.FindElement(By.Id("industry")); var country = driver.FindElement(By.Id("country")); var selectIndustry = new SelectElement(industry); selectIndustry.SelectByValue("Education"); var selectCountry = new SelectElement(country); selectCountry.SelectByValue("US"); Console.WriteLine("Automation script for Google Cloud Next '18 event form complete"); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void DownloadCouncilPdfFiles() { var docs = this.LoadDocumentsDoneSQL(); var queries = this.LoadQueriesDoneSQL(); WebClient c = new WebClient(); ChromeDriver cd = new ChromeDriver(); foreach (string url in this.docUrls) { string category = url.Split('*')[0]; string categoryUrl = url.Split('*')[1]; cd.Navigate().GoToUrl(categoryUrl); System.Threading.Thread.Sleep(3000); var selectList = cd.FindElementsByXPath("//select"); var goList = cd.FindElementsByXPath("//a[text()='Go']"); string currentWindowHandle = cd.CurrentWindowHandle; for (int i = 0; i < selectList.Count; i++) { SelectElement fileListSelectEle = new SelectElement(selectList[i]); Dictionary <string, string> optionValues = fileListSelectEle.Options.ToDictionary(t => t.GetAttribute("value"), t => t.Text); var dateReg = new System.Text.RegularExpressions.Regex("[a-zA-Z]+[\\s]{1}[0-9]{1,2},[\\s]{1}[0-9]{4}"); bool reachlast = false; for (int j = 0; j < optionValues.Count; j++) { string value = optionValues.ElementAt(j).Key; string text = optionValues.ElementAt(j).Value; string meetingDateText = dateReg.Match(text).ToString(); DateTime meetingDate = DateTime.Parse(meetingDateText); if (meetingDate < this.dtStartFrom) { Console.WriteLine("Skip...."); reachlast = true; break; } fileListSelectEle.SelectByValue(value); goList[i].Click(); System.Threading.Thread.Sleep(2000); string fileUrl = string.Empty; if (cd.WindowHandles.Count > 1) { string nextWindowHandle = cd.WindowHandles.FirstOrDefault(t => t != currentWindowHandle); var nextWindow = cd.SwitchTo().Window(nextWindowHandle); fileUrl = nextWindow.Url; nextWindow.Close(); cd.SwitchTo().Window(currentWindowHandle); Console.WriteLine("Sleep 3 seconds..."); System.Threading.Thread.Sleep(3000); } else { fileUrl = cd.Url; } this.ExtractADoc(c, fileUrl, category, "pdf", meetingDate, ref docs, ref queries); Console.WriteLine("DEBUG INFO BEFORE RETURN TO HOME PAGE"); cd.Navigate().GoToUrl(categoryUrl); System.Threading.Thread.Sleep(3000); Console.WriteLine("DEBUG INFO AFTER RETURN TO HOME PAGE"); selectList = cd.FindElementsByXPath("//select"); goList = cd.FindElementsByXPath("//a[text()='Go']"); fileListSelectEle = new SelectElement(selectList[i]); } if (reachlast) { Console.WriteLine("Reach last...."); break; } } } cd.Quit(); cd = null; }
public static void Main(string[] args) { using (IWebDriver driver = new ChromeDriver()) { driver.Navigate().GoToUrl("https://srh.bankofchina.com/search/whpj/searchen.jsp"); var startDate = driver.FindElement(By.Name("erectDate")); var endDate = driver.FindElement(By.Name("nothing")); var currency = driver.FindElement(By.Name("pjname")); var selectElement = new SelectElement(currency); var nextPage = driver.FindElements(By.XPath("/html/body/table[3]/tbody/tr/td/div/span")); var searchButton = driver.FindElement(By.XPath("//input[@value='search']")); startDate.SendKeys("2020-12-24"); endDate.SendKeys("2020-12-26"); selectElement.SelectByValue("EUR"); searchButton.Click(); Thread.Sleep(1000); var nextPageBtn = driver.FindElement(By.XPath("/html/body/table[3]/tbody/tr/td/div/span[3]/a")); var lastElement = driver.FindElement(By.XPath("//*[contains(@title, \"Last Page\")]/a")).Text; int elementNum; bool success = Int32.TryParse(lastElement, out elementNum); var tableDataElementsHeader = driver.FindElements(By.XPath("/html/body/table[2]/tbody/tr[1]/td")); var tableDataElements = driver.FindElements(By.XPath("/html/body/table[2]/tbody/tr/td")); List <string> tableDataHeader = new List <string>(); List <string> tableData = new List <string>(); for (int i = 0; i < tableDataElementsHeader.Count; i++) { var innerHtml = tableDataElementsHeader[i].GetAttribute("innerHTML"); Console.Write(innerHtml); tableDataHeader.Add(innerHtml.ToString()); } for (int i = 0; i < elementNum; i++) { tableDataElements = driver.FindElements(By.XPath("/html/body/table[2]/tbody/tr/td")); for (int j = 7; j < tableDataElements.Count; j++) { try { var innerHtml = tableDataElements[j].GetAttribute("innerHTML"); Console.Write(innerHtml); tableData.Add(innerHtml.ToString()); } catch (Exception ex) { Console.WriteLine(ex); } } try { nextPageBtn = driver.FindElement(By.XPath("/html/body/table[3]/tbody/tr/td/div/span[3]/a")); tableData.Add("Strana " + i + " ---------\n"); nextPageBtn.Click(); Thread.Sleep(2000); } catch (StaleElementReferenceException ex) { Console.WriteLine(ex); } } string fileLocation = @"result.txt"; using (StreamWriter streamWriter = File.CreateText(fileLocation)) { if (fileLocation.Contains("result.txt")) { streamWriter.Write(String.Empty); for (int i = 0; i < tableDataHeader.Count; i++) { streamWriter.Write(String.Format("{0}; ", tableDataHeader[i])); } streamWriter.Write("\n"); for (int i = 0; i < tableData.Count; i++) { streamWriter.Write(String.Format("{0}; ", tableData[i])); if (tableData[i].Contains(":")) { streamWriter.Write("\n"); } } } } driver.Quit(); Console.ReadKey(); } }
public void Task12_Case_CreateCustomer() { //Login wait.Until(ExpectedConditions.TitleIs(EXPECTED_TITLE)); var loginField = this.driver.FindElement(By.XPath(".//input[@name='username']")); var pwdField = this.driver.FindElement(By.XPath(".//input[@name='password']")); var loginBtn = this.driver.FindElement(By.XPath(".//button[@name='login']")); loginField.Clear(); loginField.SendKeys(ADMIN_LOGIN); pwdField.Clear(); pwdField.SendKeys(ADMIN_PASSWORD); loginBtn.Click(); driver.FindElement(By.XPath(".//li[contains(@id,'app-')]/a//span[contains(text(),'Catalog')]")).Click(); driver.FindElement(By.XPath(".//a[contains(text(),'Add New Product')]")).Click(); driver.FindElement(By.XPath(".//input[@name='status' and @value='1']")).Click(); var nameField = driver.FindElement(By.XPath(".//input[contains(@name,'name')]")); var codeField = driver.FindElement(By.XPath(".//input[contains(@name,'code')]")); driver.FindElement(By.XPath($".//td[text()='{PRODUCT_GROUP}']/../td[1]")).Click(); var quantityField = driver.FindElement(By.XPath(".//input[@name='quantity']")); var quantityUnitSelect = driver.FindElement(By.XPath(".//select[@name='quantity_unit_id']")); var deliveryStatusSelect = driver.FindElement(By.XPath(".//select[@name='delivery_status_id']")); var soldOutStatusSelect = driver.FindElement(By.XPath(".//select[@name='sold_out_status_id']")); var dateValidFrom = driver.FindElement(By.XPath(".//input[@name='date_valid_from']")); var dateValidTo = driver.FindElement(By.XPath(".//input[@name='date_valid_to']")); var imagePath = Directory.GetCurrentDirectory() + @"\images\productImage.jpg"; var productImageUpload = driver.FindElement(By.XPath(".//input[@name='new_images[]']")); var productName = $"Test Product {Guid.NewGuid()}"; nameField.Clear(); nameField.SendKeys(productName); var productCode = $"Test Code {Guid.NewGuid()}"; codeField.Clear(); codeField.SendKeys(productCode); quantityField.Clear(); quantityField.SendKeys("1"); var quantityUnitSelector = new SelectElement(quantityUnitSelect); quantityUnitSelector.SelectByText("pcs"); var deliveryStatusSelector = new SelectElement(deliveryStatusSelect); deliveryStatusSelector.SelectByText("3-5 days"); var soldOutStatusSelector = new SelectElement(soldOutStatusSelect); soldOutStatusSelector.SelectByText("Sold out"); productImageUpload.SendKeys(imagePath); dateValidFrom.SendKeys("01.01.1970"); dateValidTo.SendKeys("31.12.2018"); var informationTab = driver.FindElement(By.XPath(".//a[text()='Information']")); informationTab.Click(); System.Threading.Thread.Sleep(5000); var manufacturerSelect = driver.FindElement(By.XPath(".//select[@name='manufacturer_id']")); //var supplierSelect = driver.FindElement(By.XPath(".//select[@name='supplier_id']")); var keywordsField = driver.FindElement(By.XPath(".//input[@name='keywords']")); var shortDescription = driver.FindElement(By.XPath(".//input[contains(@name,'short_description')]")); var descriptionField = driver.FindElement(By.XPath(".//div[contains(@class,'trumbowyg-editor')]")); var headTitleField = driver.FindElement(By.XPath(".//input[contains(@name,'head_title')]")); var metaDescriptionField = driver.FindElement(By.XPath(".//input[contains(@name,'meta_description')]")); var manufacturerSelector = new SelectElement(manufacturerSelect); manufacturerSelector.SelectByText("ACME Corp."); keywordsField.Clear(); keywordsField.SendKeys("KeyWords"); shortDescription.Clear(); shortDescription.SendKeys("Short Description"); new Actions(driver).SendKeys(descriptionField, "Description").Perform(); headTitleField.Clear(); headTitleField.SendKeys("HeadTitle"); metaDescriptionField.Clear(); metaDescriptionField.SendKeys("Meta Description"); var pricesTab = driver.FindElement(By.XPath(".//a[text()='Prices']")); pricesTab.Click(); var purchasePriceField = driver.FindElement(By.XPath(".//input[@name='purchase_price']")); var currencySelect = driver.FindElement(By.XPath(".//select[@name='purchase_price_currency_code']")); var saveButton = driver.FindElement(By.XPath(".//button[@name='save']")); purchasePriceField.Clear(); purchasePriceField.SendKeys("1,00"); var currencySelector = new SelectElement(currencySelect); currencySelector.SelectByValue("USD"); saveButton.Click(); }
public async override Task RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; var vTimeout = (int)await v_Timeout.EvaluateCode(engine); var seleniumSearchParamRows = (from rw in v_SeleniumSearchParameters.AsEnumerable() where rw.Field <string>("Enabled") == "True" && rw.Field <string>("Parameter Value").ToString() != "" select rw.ItemArray.Cast <string>().ToArray()).ToList(); var browserObject = ((OBAppInstance)await v_InstanceName.EvaluateCode(engine)).Value; var seleniumInstance = (IWebDriver)browserObject; dynamic element = await CommandsHelper.FindElement(engine, seleniumInstance, seleniumSearchParamRows, v_SeleniumSearchOption, vTimeout); if (element == null && v_SeleniumElementAction != "Element Exists") { throw new ElementNotVisibleException("Unable to find element within the provided time limit"); } if (v_SeleniumElementAction.Contains("Click")) { int seleniumWindowHeightY = seleniumInstance.Manage().Window.Size.Height; int elementPositionY = ((IWebElement)element).Location.Y; if (elementPositionY > seleniumWindowHeightY) { string scroll = string.Format("window.scroll(0, {0})", elementPositionY); IJavaScriptExecutor js = browserObject as IJavaScriptExecutor; js.ExecuteScript(scroll); } } Actions actions = new Actions(seleniumInstance); switch (v_SeleniumElementAction) { case "Invoke Click": ((IWebElement)element).Click(); break; case "Left Click": actions.Click((IWebElement)element).Perform(); break; case "Right Click": actions.ContextClick((IWebElement)element).Perform(); break; case "Middle Click": string userXAdjustString = (from rw in v_WebActionParameterTable.AsEnumerable() where rw.Field <string>("Parameter Name") == "X Adjustment" select rw.Field <string>("Parameter Value")).FirstOrDefault(); int userXAdjust = (int)await userXAdjustString.EvaluateCode(engine); string userYAdjustString = (from rw in v_WebActionParameterTable.AsEnumerable() where rw.Field <string>("Parameter Name") == "Y Adjustment" select rw.Field <string>("Parameter Value")).FirstOrDefault(); int userYAdjust = (int)await userYAdjustString.EvaluateCode(engine); var elementLocation = ((IWebElement)element).Location; var seleniumWindowPosition = seleniumInstance.Manage().Window.Position; User32Functions.SendMouseMove(seleniumWindowPosition.X + elementLocation.X + userXAdjust, seleniumWindowPosition.Y + elementLocation.Y + userYAdjust, v_SeleniumElementAction); break; case "Double Left Click": actions.DoubleClick((IWebElement)element).Perform(); break; case "Hover Over Element": string hoverTime = (from rw in v_WebActionParameterTable.AsEnumerable() where rw.Field <string>("Parameter Name") == "Hover Time (Seconds)" select rw.Field <string>("Parameter Value")).FirstOrDefault(); int hoverTimeInt = (int)await hoverTime.EvaluateCode(engine) * 1000; actions.MoveToElement((IWebElement)element).Perform(); Thread.Sleep(hoverTimeInt); break; case "Set Text": string textToSetString = (from rw in v_WebActionParameterTable.AsEnumerable() where rw.Field <string>("Parameter Name") == "Text To Set" select rw.Field <string>("Parameter Value")).FirstOrDefault(); string textToSet = (string)await textToSetString.EvaluateCode(engine); string clearElement = (from rw in v_WebActionParameterTable.AsEnumerable() where rw.Field <string>("Parameter Name") == "Clear Element Before Setting Text" select rw.Field <string>("Parameter Value")).FirstOrDefault(); if (clearElement == null) { clearElement = "No"; } if (clearElement.ToLower() == "yes") { ((IWebElement)element).Clear(); } string[] potentialKeyPresses = textToSet.Split('[', ']'); Type seleniumKeys = typeof(OpenQA.Selenium.Keys); FieldInfo[] fields = seleniumKeys.GetFields(BindingFlags.Static | BindingFlags.Public); //check if chunked string contains a key press command like {ENTER} foreach (string chunkedString in potentialKeyPresses) { if (chunkedString == "") { continue; } if (fields.Any(f => f.Name.ToLower() == chunkedString.ToLower()) && textToSet.Contains($"[{chunkedString}]")) { string keyPress = (string)fields.Where(f => f.Name.ToLower() == chunkedString.ToLower()).FirstOrDefault().GetValue(null); textToSet = textToSet.Replace($"[{chunkedString}]", keyPress); } } ((IWebElement)element).SendKeys(textToSet); break; case "Set Secure Text": var secureString = (from rw in v_WebActionParameterTable.AsEnumerable() where rw.Field <string>("Parameter Name") == "Secure String Variable" select rw.Field <string>("Parameter Value")).FirstOrDefault(); string _clearElement = (from rw in v_WebActionParameterTable.AsEnumerable() where rw.Field <string>("Parameter Name") == "Clear Element Before Setting Text" select rw.Field <string>("Parameter Value")).FirstOrDefault(); var secureStrVariable = (SecureString)await secureString.EvaluateCode(engine); secureString = secureStrVariable.ConvertSecureStringToString(); if (_clearElement == null) { _clearElement = "No"; } if (_clearElement.ToLower() == "yes") { ((IWebElement)element).Clear(); } string[] _potentialKeyPresses = secureString.Split('[', ']'); Type _seleniumKeys = typeof(OpenQA.Selenium.Keys); FieldInfo[] _fields = _seleniumKeys.GetFields(BindingFlags.Static | BindingFlags.Public); string _finalTextToSet = ""; //check if chunked string contains a key press command like {ENTER} foreach (string chunkedString in _potentialKeyPresses) { if (chunkedString == "") { continue; } if (_fields.Any(f => f.Name.ToLower() == chunkedString.ToLower()) && secureString.Contains("[" + chunkedString + "]")) { string keyPress = (string)_fields.Where(f => f.Name.ToLower() == chunkedString.ToLower()).FirstOrDefault().GetValue(null); _finalTextToSet += keyPress; } else { _finalTextToSet += chunkedString; } } ((IWebElement)element).SendKeys(_finalTextToSet); break; case "Get Options": string applyToVarName = (from rw in v_WebActionParameterTable.AsEnumerable() where rw.Field <string>("Parameter Name") == "Variable Name" select rw.Field <string>("Parameter Value")).FirstOrDefault(); string attribNameString = (from rw in v_WebActionParameterTable.AsEnumerable() where rw.Field <string>("Parameter Name") == "Attribute Name" select rw.Field <string>("Parameter Value")).FirstOrDefault(); string attribName = (string)await attribNameString.EvaluateCode(engine); var optionsItems = new List <string>(); var ele = (IWebElement)element; var select = new SelectElement(ele); var options = select.Options; foreach (var option in options) { var optionValue = option.GetAttribute(attribName); optionsItems.Add(optionValue); } optionsItems.SetVariableValue(engine, applyToVarName); break; case "Select Option": string selectionType = (from rw in v_WebActionParameterTable.AsEnumerable() where rw.Field <string>("Parameter Name") == "Selection Type" select rw.Field <string>("Parameter Value")).FirstOrDefault(); string selectionParamString = (from rw in v_WebActionParameterTable.AsEnumerable() where rw.Field <string>("Parameter Name") == "Selection Parameter" select rw.Field <string>("Parameter Value")).FirstOrDefault(); string selectionParam = (string)await selectionParamString.EvaluateCode(engine); seleniumInstance.SwitchTo().ActiveElement(); var el = (IWebElement)element; var selectionElement = new SelectElement(el); switch (selectionType) { case "Select By Index": selectionElement.SelectByIndex(int.Parse(selectionParam)); break; case "Select By Text": selectionElement.SelectByText(selectionParam); break; case "Select By Value": selectionElement.SelectByValue(selectionParam); break; case "Deselect By Index": selectionElement.DeselectByIndex(int.Parse(selectionParam)); break; case "Deselect By Text": selectionElement.DeselectByText(selectionParam); break; case "Deselect By Value": selectionElement.DeselectByValue(selectionParam); break; case "Deselect All": selectionElement.DeselectAll(); break; default: throw new NotImplementedException(); } break; case "Get Text": case "Get Attribute": case "Get Count": string VariableName = (from rw in v_WebActionParameterTable.AsEnumerable() where rw.Field <string>("Parameter Name") == "Variable Name" select rw.Field <string>("Parameter Value")).FirstOrDefault(); string attributeNameString = (from rw in v_WebActionParameterTable.AsEnumerable() where rw.Field <string>("Parameter Name") == "Attribute Name" select rw.Field <string>("Parameter Value")).FirstOrDefault(); string attributeName = (string)await attributeNameString.EvaluateCode(engine); string elementValue; if (v_SeleniumElementAction == "Get Text") { elementValue = element.Text; } else if (v_SeleniumElementAction == "Get Count") { elementValue = "1"; if (element is ReadOnlyCollection <IWebElement> ) { elementValue = ((ReadOnlyCollection <IWebElement>)element).Count().ToString(); } } else { elementValue = ((IWebElement)element).GetAttribute(attributeName); } elementValue.SetVariableValue(engine, VariableName); break; case "Get Matching Element(s)": var variableName = (from rw in v_WebActionParameterTable.AsEnumerable() where rw.Field <string>("Parameter Name") == "Variable Name" select rw.Field <string>("Parameter Value")).FirstOrDefault(); if (!(element is IWebElement)) { //create element list List <IWebElement> elementList = new List <IWebElement>(); foreach (IWebElement item in element) { elementList.Add(item); } elementList.SetVariableValue(engine, variableName); } else { ((IWebElement)element).SetVariableValue(engine, variableName); } break; case "Get Table": var DTVariableName = (from rw in v_WebActionParameterTable.AsEnumerable() where rw.Field <string>("Parameter Name") == "Variable Name" select rw.Field <string>("Parameter Value")).FirstOrDefault(); // Get HTML (Source) of the Element string tableHTML = ((IWebElement)element).GetAttribute("innerHTML").ToString(); HtmlDocument doc = new HtmlDocument(); //Load Source (String) as HTML Document doc.LoadHtml(tableHTML); //Get Header Tags var headers = doc.DocumentNode.SelectNodes("//tr/th"); DataTable DT = new DataTable(); //If headers found if (headers != null && headers.Count != 0) { // add columns from th (headers) foreach (HtmlNode header in headers) { DT.Columns.Add(Regex.Replace(header.InnerText, @"\t|\n|\r", "").Trim()); } } else { var columnsCount = doc.DocumentNode.SelectSingleNode("//tr[1]").ChildNodes.Where(node => node.Name == "td").Count(); DT.Columns.AddRange((Enumerable.Range(1, columnsCount).Select(dc => new DataColumn())).ToArray()); } // select rows with td elements and load each row (containing <td> tags) into DataTable foreach (var row in doc.DocumentNode.SelectNodes("//tr[td]")) { DT.Rows.Add(row.SelectNodes("td").Select(td => Regex.Replace(td.InnerText, @"\t|\n|\r", "").Trim()).ToArray()); } DT.SetVariableValue(engine, DTVariableName); break; case "Clear Element": ((IWebElement)element).Clear(); break; case "Switch to Frame": if (seleniumSearchParamRows.Count == 0) { seleniumInstance.SwitchTo().DefaultContent(); } else { seleniumInstance.SwitchTo().Frame((IWebElement)element); } break; case "Wait For Element To Exist": break; case "Element Exists": string existsBoolVariableName = (from rw in v_WebActionParameterTable.AsEnumerable() where rw.Field <string>("Parameter Name") == "Variable Name" select rw.Field <string>("Parameter Value")).FirstOrDefault(); if (element == null) { false.SetVariableValue(engine, existsBoolVariableName); } else { true.SetVariableValue(engine, existsBoolVariableName); } break; default: throw new Exception("Element Action was not found"); } }
public static void SelectByValue(this IWebElement element, string value) { SelectElement select = new SelectElement(element); select.SelectByValue(value); }
public void PD_Fields__Mandatory() { // IWebDriver driver; Thread.Sleep(2000); driver.Manage().Window.Maximize(); WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5)); // Thread.Sleep(1000); // driver.FindElement(By.XPath(".//*[@id='ctl00_ctl00_AdminLink']")).Click(); driver.FindElement(By.XPath(".//*[@id='aspnetForm']/section[2]/section[1]/nav")).Click(); Console.WriteLine("Black Ribbon"); Thread.Sleep(1000); driver.FindElement(By.XPath("//a[contains(@title, 'Search client')]")).Click(); // wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//a[contains(@title, 'Management')]"))); Console.WriteLine("Search client"); Thread.Sleep(1000); Console.WriteLine("Clicked Search"); // driver.FindElement(By.XPath(".//*[@id='ctl00_ctl00_cph1_cph1_HyperLinkAdminPlanners']")).Click(); driver.FindElement(By.XPath(".//*[@id='ctl00_ctl00_cph1_cph1_btnSearch']")).Click(); Console.WriteLine("sEARCH"); Thread.Sleep(1000); IWebElement element = driver.FindElement(By.Id("ctl00_ctl00_cph1_cph1_ClientName")); var C_USERNAME = System.Configuration.ConfigurationManager.AppSettings["C_USERNAME"]; Console.WriteLine(string.Format("Given Name is : ", C_USERNAME)); element.SendKeys(C_USERNAME); // driver.FindElement(By.Id("ctl00_ctl00_cph1_cph1_ClientName")).SendKeys("Jeff1"); Console.WriteLine("Enter Search"); Thread.Sleep(1000); driver.FindElement(By.XPath(".//*[@id='ctl00_ctl00_cph1_cph1_btnSearch']")).Click(); Console.WriteLine("Click on Search button"); for (int i = 0; i <= 20; i++) { // String ss = driver.FindElement(By.XPath(".//*[@id='ctl00_ctl00_cph1_cph1_rgManageAR_ctl00__" + i + "']/td[2]")).Text; String gn = driver.FindElement(By.XPath(".//*[@id='ctl00_ctl00_cph1_cph1_rgUsers_ctl00__" + i + "']/td[4]")).Text; string s = System.Configuration.ConfigurationManager.AppSettings["C_USERNAME"]; if (!String.IsNullOrEmpty(s)) { Console.WriteLine("C_Given Name is:" + gn); String sn = driver.FindElement(By.XPath(".//*[@id='ctl00_ctl00_cph1_cph1_rgUsers_ctl00__" + i + "']/td[5]")).Text; string s1 = System.Configuration.ConfigurationManager.AppSettings["C_GIVEN NAME"]; if (!String.IsNullOrEmpty(s1)) { Console.WriteLine("Given Name is:" + sn); Console.WriteLine("Into Loop i is +" + i); var im1 = driver.FindElement(By.XPath(".//*[@id='ctl00_ctl00_cph1_cph1_rgUsers_ctl00__" + i + "']/td[7]")); Console.WriteLine("i value chk is +" + i); im1.Click(); break; } } } Thread.Sleep(1000); driver.FindElement(By.XPath("//*[@id='hlFacts']")).Click(); /**************OK PD Express**/ Thread.Sleep(2000); driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_hlPersonalDetails']")).Click(); Console.WriteLine("Click on Personal Details "); Thread.Sleep(1000); var pdf_filename = "D:\\PDF Test123.pdf"; var reader = new PdfReader(pdf_filename); // { var fields = reader.AcroFields.Fields; /*** string val = reader.AcroFields.GetField("UserName"); * * string val1 = reader.AcroFields.GetField("Password");***/ string val = reader.AcroFields.GetField("SaveInputJSON.PersonalDetails.0.PersonalDetails.user"); string val1 = reader.AcroFields.GetField("SaveInputJSON.PersonalDetails.1.PersonalDetails.user"); string val2 = reader.AcroFields.GetField("SaveInputJSON.Date"); string val3 = reader.AcroFields.GetField("SaveInputJSON.PersonalDetails.0.PersonalDetails.data.0.PersonalDetailsData.items.0.PersonalDetailsItem.GivenNames"); // SaveInputJSON.PersonalDetails.0.PersonalDetails.user // SaveInputJSON.PersonalDetails.1.PersonalDetails.user // Response.Write("SaveInputJSON.ClientName" + " : " + val + " <br/"); Console.WriteLine("Client+" + val); Console.WriteLine("Partner+" + val1); Console.WriteLine("Date+" + val2); Console.WriteLine("Date+" + val3); // string S1 = System.Configuration.ConfigurationManager.AppSettings["C_GIVEN NAME"]; driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_txtClientGivenNames']")).Clear(); driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_txtClientGivenNames']")).SendKeys(val3); string S2 = System.Configuration.ConfigurationManager.AppSettings["C_SUR NAME"]; driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_txtClientSurname']")).Clear(); // driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_txtClientSurname']")).SendKeys(S2); string val5 = reader.AcroFields.GetField("SaveInputJSON.PersonalDetails.0.PersonalDetails.data.0.PersonalDetailsData.items.0.PersonalDetailsItem.DateOfBirth"); Console.WriteLine("Date is" + val5); // string S6 = System.Configuration.ConfigurationManager.AppSettings["C_DOB"]; driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_txtClientDateOfBirth']")).Clear(); driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_txtClientDateOfBirth']")).SendKeys(val5); // driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_txtClientDateOfBirth']")).SendKeys(S6); // Console.WriteLine("Enter DOB"); /* SaveInputJSON.PersonalDetails.0.PersonalDetails.data.0.PersonalDetailsData.items.0.PersonalDetailsItem.Gender * SaveInputJSON.PersonalDetails.0.PersonalDetails.data.0.PersonalDetailsData.items.0.PersonalDetailsItem.Gender * * SaveInputJSON.PersonalDetails.0.PersonalDetails.data.0.PersonalDetailsData.items.0.PersonalDetailsItem.Gender * SaveInputJSON.PersonalDetails.0.PersonalDetails.data.0.PersonalDetailsData.items.0.PersonalDetailsItem.Gender*/ string val6 = reader.AcroFields.GetField("SaveInputJSON.PersonalDetails.0.PersonalDetails.data.0.PersonalDetailsData.items.0.PersonalDetailsItem.Gender"); Console.WriteLine("Gender is" + val6); if (val6 == "Male") { // driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_rbClientGenderMale']")).Click(); driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_rbClientGenderFemale']")).Click(); } // val6.Click(); // driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_rbClientGenderMale']")).Click(); Thread.Sleep(1000); wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[1]/div[2]/div[2]/div/div[1]/div/div/div[1]/table/tbody/tr[5]/td"))); string val4 = reader.AcroFields.GetField("SaveInputJSON.PersonalDetails.0.PersonalDetails.data.0.PersonalDetailsData.items.0.PersonalDetailsItem.MaritalStatus"); Console.WriteLine("MS" + val4); // SelectElement oSelection = new SelectElement(driver.FindElement(By.Id("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_ddlClientMaritalStatus']"))); SelectElement oSelection = new SelectElement(driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_ddlClientMaritalStatus']"))); // string S7 = System.Configuration.ConfigurationManager.AppSettings["C_MS"]; // string S7 = System.Configuration.ConfigurationManager.AppSettings["val4"]; // oSelection.SelectByText(val4); oSelection.SelectByValue(val4); /* IJavaScriptExecutor js = (IJavaScriptExecutor)driver; * IWebElement ej = driver.FindElement(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[1]/div[2]/div[2]/div/div[1]/div/div/div[1]/table/tbody/tr[5]/td")); * // ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView();" * // , element); * * * * js.ExecuteScript("arguments[3].click();", ej); * * Console.WriteLine("JS CHK ");*/ Thread.Sleep(1000); driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_ClientTFN']")).Clear(); string S8 = System.Configuration.ConfigurationManager.AppSettings["C_TFN"]; // driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_ClientTFN']")).SendKeys(S8); Console.WriteLine("TFN"); /* driver.FindElement(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[2]/div/div[1]/a")).Click(); * * * Console.WriteLine("Profile SAVE");*/ Thread.Sleep(1000); driver.FindElement(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[1]/div[2]/div[2]/div/div[1]/ul/li[2]/a")).Click(); string S9 = System.Configuration.ConfigurationManager.AppSettings["C_MOB"]; driver.FindElement(By.XPath("//*[@id='txtClientMobilePhone']")).Clear(); // driver.FindElement(By.XPath("//*[@id='txtClientMobilePhone']")).SendKeys(S9); string S10 = System.Configuration.ConfigurationManager.AppSettings["C_EMAIL"]; driver.FindElement(By.XPath("//*[@id='txtClientEmail']")).Clear(); // driver.FindElement(By.XPath("//*[@id='txtClientEmail']")).SendKeys(S10); string S11 = System.Configuration.ConfigurationManager.AppSettings["C_SKYPE"]; driver.FindElement(By.XPath("//*[@id='txtClientSkypeUsername']")).Clear(); // driver.FindElement(By.XPath("//*[@id='txtClientSkypeUsername']")).SendKeys(S11); driver.FindElement(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[2]/div/div[1]/a")).Click(); Console.WriteLine("Contact SAVE"); driver.FindElement(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[1]/div[2]/div[2]/div/div[1]/ul/li[3]/a")).Click(); string S12 = System.Configuration.ConfigurationManager.AppSettings["C_ADDR1"]; driver.FindElement(By.XPath("//*[@id='txtClientAddress1']")).Clear(); // driver.FindElement(By.XPath("//*[@id='txtClientAddress1']")).SendKeys(S12); string S13 = System.Configuration.ConfigurationManager.AppSettings["C_ADDR2"]; driver.FindElement(By.XPath("//*[@id='txtClientAddress2']")).Clear(); // driver.FindElement(By.XPath("//*[@id='txtClientAddress2']")).SendKeys(S13); string S14 = System.Configuration.ConfigurationManager.AppSettings["C_SUBR"]; driver.FindElement(By.XPath("//*[@id='txtClientSuburb']")).Clear(); // driver.FindElement(By.XPath("//*[@id='txtClientSuburb']")).SendKeys(S14); Thread.Sleep(1000); //*[@id="ddlClientState"] string S15 = System.Configuration.ConfigurationManager.AppSettings["C_STA"]; SelectElement oSelection2 = new SelectElement(driver.FindElement(By.XPath("//*[@id='ddlClientState']"))); oSelection2.SelectByText(S15); string S16 = System.Configuration.ConfigurationManager.AppSettings["C_PC"]; driver.FindElement(By.XPath("//*[@id='txtClientPostcode']")).Clear(); // driver.FindElement(By.XPath("//*[@id='txtClientPostcode']")).SendKeys(S16); string S17 = System.Configuration.ConfigurationManager.AppSettings["C_Cntry"]; SelectElement oSelection3 = new SelectElement(driver.FindElement(By.XPath("//*[@id='ddlClientCountry']"))); oSelection3.SelectByText(S17); /* driver.FindElement(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[2]/div/div[1]/a")).Click(); * * Console.WriteLine("Address SAVE");*/ Thread.Sleep(1000); driver.FindElement(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[1]/div[2]/div[2]/ul/li[2]/a")).Click(); Thread.Sleep(2000); string S3 = System.Configuration.ConfigurationManager.AppSettings["P_GIVEN NAME"]; driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_txtPartnerGivenNames']")).Clear(); // driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_txtPartnerGivenNames']")).SendKeys(S3); string S4 = System.Configuration.ConfigurationManager.AppSettings["P_SUR NAME"]; driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_txtPartnerSurname']")).Clear(); /// driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_txtPartnerSurname']")).SendKeys(S4); driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_txtPartnerDateOfBirth']")).Clear(); string S5 = System.Configuration.ConfigurationManager.AppSettings["P_DOB"]; // driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_txtPartnerDateOfBirth']")).SendKeys(S5); Console.WriteLine("Enter DOB"); driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_rbPartnerGenderFemale']")).Click(); Thread.Sleep(1000); wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[1]/div[2]/div[2]/div/div[2]/div/div/div[1]/table/tbody/tr[5]/td"))); // SelectElement oSelection = new SelectElement(driver.FindElement(By.Id("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_ddlClientMaritalStatus']"))); SelectElement oSelection4 = new SelectElement(driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_ddlPartnerMaritalStatus']"))); string S18 = System.Configuration.ConfigurationManager.AppSettings["C_MS"]; oSelection4.SelectByText(S18); /* IJavaScriptExecutor js = (IJavaScriptExecutor)driver; * IWebElement ej = driver.FindElement(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[1]/div[2]/div[2]/div/div[1]/div/div/div[1]/table/tbody/tr[5]/td")); * // ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView();" * // , element); * * * * js.ExecuteScript("arguments[3].click();", ej); * * Console.WriteLine("JS CHK ");*/ Thread.Sleep(1000); driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_PartnerTFN']")).Clear(); string S19 = System.Configuration.ConfigurationManager.AppSettings["P_TFN"]; // driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_PersonalDetailsControl_PartnerTFN']")).SendKeys(S19); Console.WriteLine("TFN"); /* driver.FindElement(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[2]/div/div[1]/a")).Click(); * * * Console.WriteLine("Profile SAVE");*/ Thread.Sleep(1000); driver.FindElement(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[1]/div[2]/div[2]/div/div[2]/ul/li[2]/a")).Click(); string S20 = System.Configuration.ConfigurationManager.AppSettings["P_MOB"]; driver.FindElement(By.XPath("//*[@id='txtPartnerMobilePhone']")).Clear(); // driver.FindElement(By.XPath("//*[@id='txtPartnerMobilePhone']")).SendKeys(S20); string S21 = System.Configuration.ConfigurationManager.AppSettings["P_EMAIL"]; driver.FindElement(By.XPath("//*[@id='txtPartnerEmail']")).Clear(); // driver.FindElement(By.XPath("//*[@id='txtPartnerEmail']")).SendKeys(S21); string S22 = System.Configuration.ConfigurationManager.AppSettings["P_SKYPE"]; driver.FindElement(By.XPath("//*[@id='txtPartnerSkypeUsername']")).Clear(); // driver.FindElement(By.XPath("//*[@id='txtPartnerSkypeUsername']")).SendKeys(S22); /* driver.FindElement(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[2]/div/div[1]/a")).Click(); * Console.WriteLine("Contact SAVE");*/ Thread.Sleep(1000); driver.FindElement(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[1]/div[2]/div[2]/div/div[2]/ul/li[3]/a")).Click(); driver.FindElement(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[1]/div[2]/div[2]/div/div[2]/div/div/div[3]/table/tbody[1]/tr[2]/td/div/label/span")).Click(); /**** driver.FindElement(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[2]/div/div[1]/a")).Click(); * Console.WriteLine("Partner Contact SAVE");****/ /******OK Thread.Sleep(2000);****/ //*[@id="ctl00_ctl00_cph1_cph1_CfactsExpressControl_hlFinancialObjectives"] /***************************** * driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_hlFinancialObjectives']")).Click(); * * * // Thread.Sleep(2000); * string S268 = System.Configuration.ConfigurationManager.AppSettings["C_FO_Type"]; * SelectElement oSelection268 = new SelectElement(driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_FinancialObjectivesControl_ClientFinancialObjectiveRow_0_ddlFinancialObjectiveType']"))); * oSelection268.SelectByText(S268); * * string S269 = System.Configuration.ConfigurationManager.AppSettings["C_FO_Prio"]; * SelectElement oSelection269 = new SelectElement(driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_FinancialObjectivesControl_ClientFinancialObjectiveRow_0_ddlPriorityType']"))); * oSelection269.SelectByText(S269); * * * * driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_FinancialObjectivesControl_ClientFinancialObjectiveRow_0_txtShortTerm']")).Clear(); * * // driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_FinancialObjectivesControl_ClientFinancialObjectiveRow_0_txtShortTerm']")).SendKeys("Test Immediate"); * * driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_FinancialObjectivesControl_ClientFinancialObjectiveRow_0_txtMediumTerm']")).Clear(); * * // driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_FinancialObjectivesControl_ClientFinancialObjectiveRow_0_txtMediumTerm']")).SendKeys("Test Medium-Long Term "); * * driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_FinancialObjectivesControl_ClientFinancialObjectiveRow_0_txtLongTerm']")).Clear(); * * // driver.FindElement(By.XPath("//*[@id='ctl00_ctl00_cph1_cph1_CfactsExpressControl_FinancialObjectivesControl_ClientFinancialObjectiveRow_0_txtLongTerm']")).SendKeys("Test Ongoing "); * * * driver.FindElement(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[1]/div[3]/div[2]/ul/li[2]/a")).Click(); * * // String add = driver.FindElement(By.XPath("//*[@id='ctl00_trfinancialobjectiverow']")).Text; * // Console.WriteLine("Add FO is available or not" + add); * // if(add!="Add Financial Objective") * * driver.FindElement(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[1]/div[3]/div[2]/div/div[2]/div/a")).Click(); * //*[@id="aspnetForm"]/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[1]/div[3]/div[2]/div * //*[@id="aspnetForm"]/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[1]/div[3]/div[2]/div/div[2]/div * string S270 = System.Configuration.ConfigurationManager.AppSettings["P_FO_Type"]; * SelectElement oSelection270 = new SelectElement(driver.FindElement(By.XPath("//*[@id='ctl00_ddlFinancialObjectiveType']"))); * oSelection270.SelectByText(S270); * * * string S271 = System.Configuration.ConfigurationManager.AppSettings["P_FO_Prio"]; * SelectElement oSelection271 = new SelectElement(driver.FindElement(By.XPath("//*[@id='ctl00_ddlPriorityType']"))); * oSelection271.SelectByText(S271); * //*[@id="ctl00_ddlPriorityType"] * * * * driver.FindElement(By.XPath("//*[@id='ctl00_txtShortTerm']")).Clear(); * * // driver.FindElement(By.XPath("//*[@id='ctl00_txtShortTerm']")).SendKeys("Partner Immediate"); * * driver.FindElement(By.XPath("//*[@id='ctl00_txtMediumTerm']")).Clear(); * * // driver.FindElement(By.XPath("//*[@id='ctl00_txtMediumTerm']")).SendKeys("Partner Medium-Long Term "); * * driver.FindElement(By.XPath("//*[@id='ctl00_txtLongTerm']")).Clear(); * * // driver.FindElement(By.XPath("//*[@id='ctl00_txtLongTerm']")).SendKeys("Partner Ongoing "); * * * * Console.WriteLine("Add FO is available OK"); * driver.FindElement(By.XPath("//*[@id='aspnetForm']/section[2]/section[2]/section[1]/section/section/section/section[1]/div[3]/div[3]/div[2]/div/div[1]/a")).Click(); * *************/ }
public void Dropdown(IWebDriver driver, string dropdown_id, string value) { var crm = new SelectElement(driver.FindElement(By.Id(dropdown_id))); crm.SelectByValue(value); }
public void SelectDropDownOptionByValue(IWebElement dropDown, string value) { SelectElement select = new SelectElement(dropDown); select.SelectByValue(value); }
static void Main() { IWebDriver driver = new ChromeDriver(); //Open Webpage driver.Navigate().GoToUrl(url: "http://newtours.demoaut.com/mercurywelcome.php"); //Enter username and password driver.FindElement(By.Name("userName")).SendKeys("georgia_m"); driver.FindElement(By.Name("password")).SendKeys("Georgia2018"); driver.FindElement(By.Name("login")).Click(); IWebElement LoginElement = driver.FindElement(By.Name("findflight")); //Check for valid or invalid login if (LoginElement.Displayed) { System.Console.WriteLine("Valid login"); IWebElement RadioButton = driver.FindElement(By.Name("tripType")); if (RadioButton.GetAttribute("checked") == "true") { var DropDownMenu = driver.FindElement(By.Name("passCount")); var passno = new SelectElement(DropDownMenu); passno.SelectByValue("3"); var DropDownMenu1 = driver.FindElement(By.Name("fromPort")); var dept = new SelectElement(DropDownMenu1); dept.SelectByValue("London"); var DropDownMenu2 = driver.FindElement(By.Name("fromMonth")); var month = new SelectElement(DropDownMenu2); month.SelectByValue("11"); var DropDownMenu3 = driver.FindElement(By.Name("fromDay")); var date = new SelectElement(DropDownMenu3); date.SelectByValue("2"); var DropDownMenu4 = driver.FindElement(By.Name("toPort")); var arrival = new SelectElement(DropDownMenu4); arrival.SelectByValue("Frankfurt"); var DropDownMenu5 = driver.FindElement(By.Name("toMonth")); var ret = new SelectElement(DropDownMenu5); ret.SelectByValue("11"); var DropDownMenu6 = driver.FindElement(By.Name("toDay")); var retdate = new SelectElement(DropDownMenu6); retdate.SelectByValue("8"); IWebElement ContinueButton = driver.FindElement(By.Name("findflight")); if (ContinueButton.Displayed) { driver.FindElement(By.XPath("//img[@src='/images/masts/mast_selectflight.gif']")); System.Console.WriteLine("page found"); } else { System.Console.WriteLine("page not found"); } } else { System.Console.WriteLine("page not found"); } } else { System.Console.WriteLine("Invalid login"); } driver.Quit(); }
public static void SelectByValue(IWebElement element, String value) { select = new SelectElement(element); select.SelectByValue(value); }
public void Validatate_InvestorFund_InvestmentsMonitor_Report() { try { QAReportsDriver = objbase.Initializedriver(); QAReportsDriver.Navigate().GoToUrl(ConfigurationSettings.AppSettings["QAT"]); QAReportsDriver.Manage().Window.Maximize(); objbase.WaitforPageload(); IWebElement elelnkreport = QAReportsDriver.FindElement(By.Id("btnReports")); IJavaScriptExecutor QAReportexecutor = (IJavaScriptExecutor)QAReportsDriver; QAReportexecutor.ExecuteScript("arguments[0].click();", elelnkreport); objbase.WaitforPageload(); IWebElement tableqareportsmenu = QAReportsDriver.FindElement(By.Id("reportsMenu")); objbase.WaitforPageload(); IWebElement lnkqareports = QAReportsDriver.FindElement(By.LinkText("Hermes QA Reports")); QAReportexecutor.ExecuteScript("arguments[0].click();", lnkqareports); objbase.WaitforPageload(); QAReportsDriver.SwitchTo().Window(QAReportsDriver.WindowHandles.Last()); objbase.WaitforPageload(); // QAReportsDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20); // objbase.WaitUntilFrameLoadedAndSwitchToIt(By.Name("tabedindex")); // QAReportsDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30); QAReportsDriver.FindElement(By.Name("tabedindex")); objbase.WaitForFrameload(); var wdwaittabedindex = new WebDriverWait(QAReportsDriver, TimeSpan.FromSeconds(30)); wdwaittabedindex.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt("tabedindex")); objbase.WaitForFrameload(); IWebElement eleInvestorFund = QAReportsDriver.FindElement(By.Id("tabid1")); objbase.WaitforPageRefresh(); QAReportexecutor.ExecuteScript("arguments[0].click();", eleInvestorFund); objbase.WaitforPortfolioload(); QAReportsDriver.SwitchTo().DefaultContent(); // IWebElement frmtabview = QAReportsDriver.FindElement(By.Name("tabview")); // QAReportsDriver.SwitchTo().Frame(frmtabview).SwitchTo().Frame("frametree1"); QAReportsDriver.FindElement(By.Name("tabview")); var wdwaittabview = new WebDriverWait(QAReportsDriver, TimeSpan.FromSeconds(30)); wdwaittabview.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt("tabview")); objbase.WaitforPageload(); QAReportsDriver.FindElement(By.Name("frametree1")); objbase.WaitforPageload(); var wdwaitfrmtree1 = new WebDriverWait(QAReportsDriver, TimeSpan.FromSeconds(30)); wdwaitfrmtree1.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt("frametree1")); objbase.WaitforPageload(); IWebElement Investorfund = QAReportsDriver.FindElement(By.LinkText(ConfigurationSettings.AppSettings["InvestorSelectFund"])); QAReportexecutor.ExecuteScript("arguments[0].click();", Investorfund); objbase.WaitforPageload(); QAReportsDriver.SwitchTo().DefaultContent(); // IWebElement frmtabview1 = QAReportsDriver.FindElement(By.Name("tabview")); QAReportsDriver.FindElement(By.Name("tabview")); var wdtabview1 = new WebDriverWait(QAReportsDriver, TimeSpan.FromSeconds(30)); wdtabview1.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt("tabview")); objbase.WaitforPageload(); QAReportsDriver.FindElement(By.Name("frametree4")); var wdwaitframetree4 = new WebDriverWait(QAReportsDriver, TimeSpan.FromSeconds(30)); wdwaitframetree4.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt("frametree4")); objbase.WaitforPageload(); // QAReportsDriver.SwitchTo().Frame(frmtabview1).SwitchTo().Frame("frametree4"); IWebElement treetable = QAReportsDriver.FindElement(By.Id("tree1table")); objbase.WaitforPageRefresh(); IWebElement eleaccfeereport = treetable.FindElement(By.Id("i04")); eleaccfeereport.Click(); objbase.WaitforAlert(); // QAReportsDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); try { var potfolioloadwait = new WebDriverWait(QAReportsDriver, TimeSpan.FromSeconds(60)); potfolioloadwait.Until(ExpectedConditions.AlertIsPresent()); QAReportsDriver.SwitchTo().Alert().Accept(); objbase.WaitforPageRefresh(); } catch (Exception EX) { } // QAReportsDriver.SwitchTo().DefaultContent(); QAReportsDriver.SwitchTo().Window(QAReportsDriver.WindowHandles.Last()); // objbase.WaitforPageRefresh(); QAReportsDriver.Manage().Window.Maximize(); objbase.WaitforPageRefresh(); QAReportsDriver.FindElement(By.Name("frametree1")); objbase.WaitforPageload(); var wdframetreeforreporrtpage = new WebDriverWait(QAReportsDriver, TimeSpan.FromSeconds(30)); wdframetreeforreporrtpage.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt("frametree1")); objbase.WaitforPageload(); IWebElement tbltreet = QAReportsDriver.FindElement(By.Id("tree1table")); IWebElement eleportfolioid = tbltreet.FindElement(By.Id("portfolioid")); QAReportsDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); //objbase.WaitforPageRefresh(); SelectElement seleportfolioid = new SelectElement(eleportfolioid); seleportfolioid.SelectByValue(ConfigurationSettings.AppSettings["InvestorPortfolioId"]); objbase.WaitforReportPage(); QAReportsDriver.Quit(); } catch (Exception exinvestorFundInvestmentsMonitor) { Console.WriteLine("QA Investestor Fund Exception :" + exinvestorFundInvestmentsMonitor.Message.ToString()); QAReportsDriver.Quit(); } }
// select product Quantity internal void SelectQuantity_DeltaOrder(IWebDriver driver) { SelectElement quantity = new SelectElement(driver.FindElement(arrgdetailpageObject.ArrgQuantity)); quantity.SelectByValue("4"); }
public static void SelectFromDropDownByValue(IWebElement element, String value) { var selectElement = new SelectElement(element); selectElement.SelectByValue(value); }
/// <summary> /// BMW,Benz,Honda /// </summary> /// <param name="option"></param> public void selectDropDown(string option) { SelectElement el = new SelectElement(ddwn); el.SelectByValue(option.ToLower()); }
public void SelectOneFromSelectOneTwoThree() { SelectElement select = new SelectElement(selectOneTwoThree); select.SelectByValue("one"); }
public static void SelectByListValue(IWebDriver driver, string elementName, string value) { var listBox = new SelectElement(driver.FindElement(By.Id(elementName))); listBox.SelectByValue(value); }
public override void PostExecute() { IEXGateway._IEXResult res; //Setting the Device pin back to true res = CL.EA.STBSettings.ChangePinCode(Constants.newPIN, defaultPin); if (!res.CommandSucceeded) { try { LogCommentFailure(CL, "Failed to verify that the change pin codeis not reverted back to the default value"); string boxID = CL.EA.UI.Utils.GetValueFromEnvironment("BOX_ID").ToString(); if (boxID == "") { LogCommentFailure(CL, "Failed to get the BOX_ID from Environment ini"); } else { LogCommentImportant(CL, "Box ID fetched from Environment ini file is " + boxID); } string remotePSURL = CL.EA.UI.Utils.GetValueFromEnvironment("RemotePSServerURL").ToString(); if (remotePSURL == "") { LogCommentFailure(CL, "Failed to get the RemotePSServerURL from Environment ini"); } else { LogCommentImportant(CL, "RemotePSServerURL fetched from Environment ini file is " + remotePSURL); } FirefoxDriver driver = new FirefoxDriver(); driver.Navigate().GoToUrl(remotePSURL); LogCommentImportant(CL, "Navigating to the Remote PS server which is 10.201.96.19"); driver.Manage().Window.Maximize(); driver.FindElement(By.Id("element_1")).Click(); driver.FindElement(By.Id("element_1")).Clear(); driver.FindElement(By.Id("element_1")).SendKeys(boxID); LogCommentImportant(CL, "Entering the BOX ID"); CL.IEX.Wait(2); LogCommentImportant(CL, "Selecting the API in this case Reset MPIN"); SelectElement APIselector = new SelectElement(driver.FindElementById("element_2")); APIselector.SelectByIndex(3); CL.IEX.Wait(2); LogCommentImportant(CL, "Selecting the Preferred Language which is en"); SelectElement Languageselector = new SelectElement(driver.FindElementById("language")); Languageselector.SelectByValue("en"); CL.IEX.Wait(2); LogCommentImportant(CL, "Selecting the LAB which is UM"); SelectElement Labselector = new SelectElement(driver.FindElementById("lab")); Labselector.SelectByIndex(3); CL.IEX.Wait(5); driver.FindElementById("submit_form").Click(); CL.IEX.Wait(10); driver.Quit(); } catch (Exception ex) { LogCommentFailure(CL, "Failed to reset the Pin from Remote PS server. Reason :" + ex.Message); CL.IEX.Wait(10); driver.Quit(); } } CL.IEX.Wait(10); CL.EA.UI.Utils.SendIR("MENU"); CL.IEX.Wait(3); CL.EA.UI.Utils.SendIR("RETOUR"); CL.IEX.Wait(2); CL.EA.UI.Utils.SendIR("MENU"); CL.IEX.Wait(20); //Setting the Channel bar display timout to default //string defaultChannelBarTimeOut = CL.EA.GetValueFromINI(EnumINIFile.Project, "CHANNEL_BAR_TIMEOUT", "DEFAULT"); //if (string.IsNullOrEmpty(defaultChannelBarTimeOut)) //{ // LogCommentFailure(CL, "CHANNEL_BAR_TIMEOUT, DEFAULT fetched from Project.ini is null or empty"); //} //EnumChannelBarTimeout defaultChannelBarTimeOutVal; //Enum.TryParse<EnumChannelBarTimeout>(defaultChannelBarTimeOut, out defaultChannelBarTimeOutVal); //res = CL.EA.STBSettings.SetBannerDisplayTime(defaultChannelBarTimeOutVal); //if (!res.CommandSucceeded) //{ // LogCommentFailure(CL, "Failed to set the Banner Display timeout to 5"); //} ////Setting the Parental control age limit to default //string defaultPCAgeLimit = CL.EA.GetValueFromINI(EnumINIFile.Project, "PARENTAL_CONTROL_AGE_LIMIT", "DEFAULT"); //EnumParentalControlAge EnumParentalControlAgeValue; //Enum.TryParse<EnumParentalControlAge>(defaultPCAgeLimit, out EnumParentalControlAgeValue); //res = CL.EA.STBSettings.SetParentalControlAgeLimit(EnumParentalControlAgeValue); //if (!res.CommandSucceeded) //{ // LogCommentFailure(CL, "Failed to set the Parental control Age limit to Default"); //} ////Setting the start Guard time to default //string DefaultSGTValue = CL.EA.GetValueFromINI(EnumINIFile.Project, "SGT", "DEFAULT"); //res = CL.EA.STBSettings.SetGuardTime(true, DefaultSGTValue); //if (!res.CommandSucceeded) //{ // LogCommentFailure(CL,"Failed to set the Guard time to true"); //} ////Setting the Disk Space ManageMent to the Default value //res = CL.IEX.MilestonesEPG.NavigateByName("STATE:DISK SPACE MANAGEMENT"); //if (!res.CommandSucceeded) //{ // LogCommentFailure(CL, "Failed to navigate to STATE:DISK SPACE MANAGEMENT"); //} //CL.IEX.Wait(2); //string DefaultDiskSpaceManagement = CL.EA.GetValueFromINI(EnumINIFile.Project, "DISK_SPACE_MANAGEMENT", "DEFAULT"); //res= CL.IEX.MilestonesEPG.Navigate(DefaultDiskSpaceManagement); //if (!res.CommandSucceeded) //{ // LogCommentFailure(CL,"Failed to set the Disk space management to Default value"); //} ////Setting the Series recording to the Default value //res = CL.IEX.MilestonesEPG.NavigateByName("STATE:SERIES RECORDING"); //if (!res.CommandSucceeded) //{ // LogCommentFailure(CL, "Failed to navigate to STATE:SERIES RECORDING"); //} //CL.IEX.Wait(2); //string DefaultSeriesRecordingValue = CL.EA.GetValueFromINI(EnumINIFile.Project, "SERIES_RECORDING", "DEFAULT"); //res = CL.IEX.MilestonesEPG.Navigate(DefaultSeriesRecordingValue); //if (!res.CommandSucceeded) //{ // LogCommentFailure(CL, "Failed to set the SeriesRecordingValue to Default value"); //} ////Unlocking the locked service //res = CL.EA.STBSettings.SetUnLockChannel(Service_5.Name); //if (!res.CommandSucceeded) //{ // LogCommentFailure(CL, "Failed to lock the service"); //} ////Unsetting all the Favourites and setting few services as favourites //res = CL.EA.STBSettings.UnsetAllFavChannels(); //if (!res.CommandSucceeded) //{ // LogCommentFailure(CL, "Failed to unset all the services from the Favourite"); //} //Deleting all the recordings res = CL.EA.PVR.DeleteAllRecordsFromArchive(); if (!res.CommandSucceeded) { LogCommentFailure(CL, "Failed to delete all records from Archive"); } //Cancelling all bookings from planner res = CL.EA.PVR.CancelAllBookingsFromPlanner(); if (!res.CommandSucceeded) { LogCommentFailure(CL, "Failed to cancel all bookings from planner"); } res = CL.EA.STBSettings.FactoryReset(SaveRecordings: false, KeepCurrentSettings: false, PinCode: defaultPin); if (!res.CommandSucceeded) { LogCommentInfo(CL, "Failed to do the Factory reset"); } CL.IEX.Wait(60); }
public string FTP_NVWashoe(string address, string ownername, string parcelNumber, string searchType, string orderNumber, string directParcel) { GlobalClass.global_orderNo = orderNumber; HttpContext.Current.Session["orderNo"] = orderNumber; GlobalClass.global_parcelNo = parcelNumber; //GlobalClass.global_county = county; string outparcelno = "", siteaddr = "", owner1 = "", legal_desc = "", year_built = "", tax_authority = "", sub_div = "", T_legal_desc; string valued_year = "", tax_year = "", assess_land = "", ass_improve = "", ass_total = "", tax_value = "", exem = "", pathid = ""; var driverService = PhantomJSDriverService.CreateDefaultService(); driverService.HideCommandPromptWindow = true; string StartTime = "", AssessmentTime = "", TaxTime = "", CitytaxTime = "", LastEndTime = ""; using (driver = new PhantomJSDriver()) { try { StartTime = DateTime.Now.ToString("HH:mm:ss"); if (searchType == "titleflex") { gc.TitleFlexSearch(orderNumber, parcelNumber, "", address, "NV", "Washoe"); if ((HttpContext.Current.Session["TitleFlex_Search"] != null && HttpContext.Current.Session["TitleFlex_Search"].ToString() == "Yes")) { driver.Quit(); return("MultiParcel"); } else if (HttpContext.Current.Session["titleparcel"].ToString() == "") { HttpContext.Current.Session["Nodata_NVWashoe"] = "Yes"; driver.Quit(); return("No Data Found"); } parcelNumber = HttpContext.Current.Session["titleparcel"].ToString(); searchType = "parcel"; } if (searchType == "address") { driver.Navigate().GoToUrl("https://www.washoecounty.us/assessor/cama/index.php"); driver.FindElement(By.Id("street_address")).SendKeys(address); gc.CreatePdf_WOP(orderNumber, "InputPassed_AddressSearch", driver, "NV", "Washoe"); driver.FindElement(By.Name("situssubmit")).SendKeys(Keys.Enter); Thread.Sleep(7000); By Icount = By.Id("search_results_info"); if (Exists(Icount)) { // success multiparcel(orderNumber); HttpContext.Current.Session["multiParcel_NVWashoe"] = "Yes"; return("MultiParcel"); } } else if (searchType == "parcel") { driver.Navigate().GoToUrl("https://www.washoecounty.us/assessor/cama/index.php"); driver.FindElement(By.Id("parid")).SendKeys(parcelNumber); gc.CreatePdf(orderNumber, parcelNumber, "InputPassed_ParcelSearch", driver, "NV", "Washoe"); driver.FindElement(By.Id("apnsubmit")).SendKeys(Keys.Enter); Thread.Sleep(7000); } else if (searchType == "ownername") { //Thread.Sleep(3000); driver.Navigate().GoToUrl("https://www.washoecounty.us/assessor/cama/index.php"); driver.FindElement(By.Id("o_lastname")).SendKeys(ownername); gc.CreatePdf_WOP(orderNumber, "InputPassed_OwnerNameSearch", driver, "NV", "Washoe"); driver.FindElement(By.Name("ownsubmit")).SendKeys(Keys.Enter); Thread.Sleep(7000); bool norec = false; try { Thread.Sleep(3000); IWebElement norecord = driver.FindElement(By.XPath("//*[@id='search_div']/div[1]")); string[] name = ownername.Split(null); string firstname = name[0]; string lastname = name[1]; if (firstname.Contains(",") && lastname.Contains(",")) { firstname = firstname.Replace(",", "").Trim(); lastname = lastname.Replace(",", "").Trim(); } if (lastname.Length == 1) { driver.FindElement(By.Id("o_firstname")).SendKeys(firstname); gc.CreatePdf_WOP(orderNumber, "InputPassed_OwnerNameSearch", driver, "NV", "Washoe"); driver.FindElement(By.Name("ownsubmit")).SendKeys(Keys.Enter); Thread.Sleep(7000); } else { driver.FindElement(By.Id("o_firstname")).SendKeys(lastname); driver.FindElement(By.Id("o_lastname")).SendKeys(firstname); gc.CreatePdf_WOP(orderNumber, "InputPassed_OwnerNameSearch", driver, "NV", "Washoe"); driver.FindElement(By.Name("ownsubmit")).SendKeys(Keys.Enter); Thread.Sleep(7000); } } catch { } try { IWebElement multi = driver.FindElement(By.XPath("//*[@id='search_results']")); multiparcel(orderNumber); HttpContext.Current.Session["multiParcel_NVWashoe"] = "Yes"; return("MultiParcel"); } catch { } } try { IWebElement INodata = driver.FindElement(By.Id("search_div")); if (INodata.Text.Contains("No results were found")) { HttpContext.Current.Session["Nodata_NVWashoe"] = "Yes"; driver.Quit(); return("No Data Found"); } } catch { } //APN: 078-221-13 outparcelno = driver.FindElement(By.XPath("//*[@id='search_div']/div[1]/div[5]/span[1]")).Text.Trim(); outparcelno = outparcelno.Replace("APN: ", ""); string outparcelnowoh = outparcelno.Replace("-", "").Trim(); gc.CreatePdf(orderNumber, outparcelnowoh, "AssessmentDetails", driver, "NV", "Washoe"); siteaddr = driver.FindElement(By.XPath("//*[@id='owner_data']/table/tbody/tr[1]/td[2]")).Text.Trim(); owner1 = driver.FindElement(By.XPath("//*[@id='owner_data']/table/tbody/tr[2]/td[2]")).Text.Trim(); //legal_desc = driver.FindElement(By.XPath("//*[@id='owner_data']/table/tbody/tr[8]/td[2]")).Text.Replace("'", "").Trim(); sub_div = driver.FindElement(By.XPath("//*[@id='owner_data']/table/tbody/tr[9]/td[2]")).Text.Replace("'", "").Trim(); year_built = driver.FindElement(By.XPath("//*[@id='building_data']/table/tbody/tr[3]/td[2]")).Text.Trim(); string property_details = siteaddr + "~" + owner1 + "~" + legal_desc + "~" + sub_div + "~" + year_built; gc.insert_date(orderNumber, outparcelno, 1, property_details, 1, DateTime.Now); //db.ExecuteQuery("insert into data_value_master (Order_no,parcel_no,Data_Field_Text_Id,Data_Field_value,Is_Table,Sequence) values ('" + orderNumber + "','" + outparcelno + "',1 ,'" + property_details + "',1,1)"); //db.ExecuteQuery("insert into real_property (orderno, apn, address,legal_description,subdivision,year_built,owner) values ('" + orderNumber + "', '" + outparcelno + "','" + siteaddr + "','" + legal_desc + "','" + sub_div + "','" + year_built + "','" + owner1 + "')"); //valuation Information IWebElement valuetableElement = driver.FindElement(By.XPath("//*[@id='value_data']/table")); IList <IWebElement> valuetableRow = valuetableElement.FindElements(By.TagName("tr")); IList <IWebElement> valuerowTD; List <string> history = new List <string>(); List <string> taxland = new List <string>(); List <string> taximprove = new List <string>(); List <string> taxtotal = new List <string>(); List <string> assessland = new List <string>(); List <string> assessimprove = new List <string>(); List <string> assesstotal = new List <string>(); int i = 0; foreach (IWebElement row in valuetableRow) { valuerowTD = row.FindElements(By.TagName("td")); if (valuerowTD.Count != 0) { if (i == 0) { history.Add(valuerowTD[1].Text.Trim().Replace("\r\n", "")); history.Add(valuerowTD[2].Text.Trim().Replace("\r\n", "")); } else if (i == 1) { taxland.Add(valuerowTD[1].Text); taxland.Add(valuerowTD[2].Text); } else if (i == 2) { taximprove.Add(valuerowTD[1].Text); taximprove.Add(valuerowTD[2].Text); } else if (i == 3) { taxtotal.Add(valuerowTD[1].Text); taxtotal.Add(valuerowTD[2].Text); } else if (i == 4) { assessland.Add(valuerowTD[1].Text); assessland.Add(valuerowTD[2].Text); } else if (i == 5) { assessimprove.Add(valuerowTD[1].Text); assessimprove.Add(valuerowTD[2].Text); } else if (i == 6) { assesstotal.Add(valuerowTD[1].Text); assesstotal.Add(valuerowTD[2].Text); } } i++; } string assessment1 = history[0] + "~" + taxland[0] + "~" + taximprove[0] + "~" + taxtotal[0] + "~" + assessland[0] + "~" + assessimprove[0] + "~" + assesstotal[0]; string assessment2 = history[1] + "~" + taxland[1] + "~" + taximprove[1] + "~" + taxtotal[1] + "~" + assessland[1] + "~" + assessimprove[1] + "~" + assesstotal[1]; gc.insert_date(orderNumber, outparcelno, 2, assessment1, 1, DateTime.Now); gc.insert_date(orderNumber, outparcelno, 2, assessment2, 1, DateTime.Now); AssessmentTime = DateTime.Now.ToString("HH:mm:ss"); //db.ExecuteQuery("insert into data_value_master (Order_no,parcel_no,Data_Field_Text_Id,Data_Field_value,Is_Table,Sequence) values ('" + orderNumber + "','" + outparcelno + "',2 ,'" + assessment1 + "',1,1)"); //db.ExecuteQuery("insert into data_value_master (Order_no,parcel_no,Data_Field_Text_Id,Data_Field_value,Is_Table,Sequence) values ('" + orderNumber + "','" + outparcelno + "',2 ,'" + assessment2 + "',1,1)"); //db.ExecuteQuery("insert into la_assessor(order_no,parcel_no,year,land,improvements,total,net_asses_value,tax_value,total_assessment) values('" + orderNumber + "','" + outparcelno + "','" + history[0] + "','" + taxland[0] + "','" + taximprove[0] + "','" + taxtotal[0] + "','" + assessland[0] + "','" + assessimprove[0] + "','" + assesstotal[0] + "') "); //db.ExecuteQuery("insert into la_assessor(order_no,parcel_no,year,land,improvements,total,net_asses_value,tax_value,total_assessment) values('" + orderNumber + "','" + outparcelno + "','" + history[1] + "','" + taxland[1] + "','" + taximprove[1] + "','" + taxtotal[1] + "','" + assessland[1] + "','" + assessimprove[1] + "','" + assesstotal[1] + "') "); //outparcelno = "035-310-41"; //Treasurer Details driver.Navigate().GoToUrl("https://nv-washoe-treasurer.manatron.com/Tabs/TaxSearch.aspx"); var ddlsearch = driver.FindElement(By.Id("selSearchBy")); var selectElement = new SelectElement(ddlsearch); selectElement.SelectByValue("Column1="); driver.FindElement(By.Id("fldInput")).SendKeys(outparcelnowoh); var wait = new WebDriverWait(driver, TimeSpan.FromMilliseconds(3000)); wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[@id='btnsearch']"))); gc.CreatePdf(orderNumber, outparcelnowoh, "InputPassed_Tax_ParcelSearch", driver, "NV", "Washoe"); driver.FindElement((By.XPath("//*[@id='btnsearch']"))).SendKeys(Keys.Enter); Thread.Sleep(3000); driver.FindElement(By.LinkText(outparcelnowoh)).SendKeys(Keys.Enter); Thread.Sleep(2000); gc.CreatePdf(orderNumber, outparcelnowoh, "Tax_MainPage", driver, "NV", "Washoe"); T_legal_desc = driver.FindElement(By.XPath("//*[@id='lxT528']/table/tbody/tr[5]/td")).Text; tax_authority = driver.FindElement(By.XPath("//*[@id='dnn_ctr480_HtmlModule_HtmlModule_lblContent']")).Text; tax_authority = gc.Between(tax_authority, "Mailing Address:", "Overnight Address:").Trim(); //db.ExecuteQuery("update real_property set legal_description ='" + legal_desc + "', tax_authority = '" + tax_authority + "' where orderno ='" + orderNumber + "' and apn = '" + outparcelno + "' "); property_details = siteaddr + "~" + owner1 + "~" + T_legal_desc + "~" + sub_div + "~" + year_built; //db.ExecuteQuery("insert into data_value_master (Order_no,parcel_no,Data_Field_Text_Id,Data_Field_value,Is_Table,Sequence) values ('" + orderNumber + "','" + outparcelno + "',1 ,'" + property_details + "',1,1)"); gc.insert_date(orderNumber, outparcelno, 1, property_details, 1, DateTime.Now); gc.CreatePdf(orderNumber, outparcelnowoh, "TaxBill_DetailsPage", driver, "NV", "Washoe"); //*[@id="529"]/table IWebElement taxbilltable = driver.FindElement(By.XPath("//*[@id='529']/table")); IList <IWebElement> taxbilltableRow = taxbilltable.FindElements(By.TagName("tr")); int rowcount = taxbilltableRow.Count; IList <IWebElement> taxbillrowTD; int w = 1; foreach (IWebElement rowid in taxbilltableRow) { taxbillrowTD = rowid.FindElements(By.TagName("td")); if (taxbillrowTD.Count != 0 && !rowid.Text.Contains("Tax Year")) { if (w < rowcount) { string cons = taxbillrowTD[0].Text + "~" + taxbillrowTD[1].Text + "~" + taxbillrowTD[2].Text + "~" + taxbillrowTD[3].Text + "~" + taxbillrowTD[4].Text + "~" + taxbillrowTD[5].Text; gc.insert_date(orderNumber, outparcelno, 66, cons, 1, DateTime.Now); } else { string cons = "-" + "~" + "-" + "~" + "-" + "~" + "-" + "~" + "Total" + "~" + taxbillrowTD[0].Text; gc.insert_date(orderNumber, outparcelno, 66, cons, 1, DateTime.Now); } } w++; } List <string> bill_year = new List <string>(); int l = 0; for (int m = 1; m < rowcount - 1; m++) { driver.FindElement(By.XPath("//*[@id='529']/table/tbody/tr[" + m + "]/td[1]/a")).SendKeys(Keys.Enter); Thread.Sleep(2000); //installments IWebElement inst1table = driver.FindElement(By.Id("installments")); IList <IWebElement> inst1tableRow = inst1table.FindElements(By.TagName("tr")); int inst1tableRowcount = inst1tableRow.Count; IList <IWebElement> inst1rowTD; int a = 0; string inst = ""; foreach (IWebElement rowid in inst1tableRow) { inst1rowTD = rowid.FindElements(By.TagName("td")); if (inst1rowTD.Count != 0) { if (a > 0 && a < inst1tableRowcount - 1) { //installment~due_date~tax_year~tax_amount~penalty_amount~Interest~total_due inst = inst1rowTD[0].Text + "~" + inst1rowTD[1].Text + "~" + inst1rowTD[2].Text + "~" + inst1rowTD[3].Text + "~" + inst1rowTD[4].Text + "~" + inst1rowTD[5].Text + "~" + inst1rowTD[6].Text; gc.insert_date(orderNumber, outparcelno, 3, inst, 1, DateTime.Now); } if (a == inst1tableRowcount - 1) { inst = " - " + "~" + " - " + "~" + inst1rowTD[0].Text + "~" + inst1rowTD[1].Text + "~" + inst1rowTD[2].Text + "~" + inst1rowTD[3].Text + "~" + inst1rowTD[4].Text; gc.insert_date(orderNumber, outparcelno, 3, inst, 1, DateTime.Now); } } a++; } try { //Payment History IWebElement payhisttable = driver.FindElement(By.XPath("//*[@id='lxT536']/table")); IList <IWebElement> payhisttableRow = payhisttable.FindElements(By.TagName("tr")); IList <IWebElement> payhistrowTD; foreach (IWebElement rowid1 in payhisttableRow) { payhistrowTD = rowid1.FindElements(By.TagName("td")); if (payhistrowTD.Count != 0) { string bill = payhistrowTD[0].Text + "~" + payhistrowTD[1].Text + "~" + payhistrowTD[2].Text + "~" + payhistrowTD[3].Text + "~" + payhistrowTD[4].Text; gc.insert_date(orderNumber, outparcelno, 4, bill, 1, DateTime.Now); } } } catch { } //Tax Detail //*[@id="lxT534"]/table //IList<IWebElement> breakdownslist = driver.FindElements(By.XPath("//*[@id='534_" + pathid + "]/div/table")); IWebElement taxdetailtable = driver.FindElement(By.XPath("//*[@id='lxT534']/table")); IList <IWebElement> taxdetailtableRow = taxdetailtable.FindElements(By.TagName("tr")); int taxrowcount = taxdetailtableRow.Count; IList <IWebElement> taxdetailrowTD; int b = 1; string tax_breakdown = ""; foreach (IWebElement rowid1 in taxdetailtableRow) { taxdetailrowTD = rowid1.FindElements(By.TagName("td")); if (taxdetailrowTD.Count != 0 && b <= taxrowcount) { if (b % 2 == 0 && b != taxrowcount) { if (l == 0) { pathid = driver.FindElement(By.XPath("//*[@id=\"lxT534\"]/table/tbody/tr[" + b + "]/td[1]")).GetAttribute("tb"); driver.FindElement(By.XPath("//*[@id='lxT534']/table/tbody/tr[" + b + "]/td[1]/a")).SendKeys(Keys.Enter); Thread.Sleep(2000); } tax_breakdown = taxdetailrowTD[0].Text + "~" + "-" + "~" + taxdetailrowTD[1].Text + "~" + taxdetailrowTD[2].Text + "~" + taxdetailrowTD[3].Text; gc.insert_date(orderNumber, outparcelno, 5, tax_breakdown, 1, DateTime.Now); //db.ExecuteQuery("insert into data_value_master (Order_no,parcel_no,Data_Field_Text_Id,Data_Field_value,Is_Table,Sequence) values ('" + orderNumber + "','" + outparcelno + "',5,'" + tax_breakdown + "',1,1)"); //db.ExecuteQuery("insert into tax_breakdown_details (order_no, parcel_no,tax_authority,gross_tax,credit,net_tax) values ('" + orderNumber + "', '" + outparcelno + "', '" + taxdetailrowTD[0].Text + "', '" + taxdetailrowTD[1].Text + "', '" + taxdetailrowTD[2].Text + "', '" + taxdetailrowTD[3].Text + "')"); } if (b == taxrowcount) { tax_breakdown = "Total Tax" + "~" + "-" + "~" + taxdetailrowTD[0].Text + "~" + taxdetailrowTD[1].Text + "~" + taxdetailrowTD[2].Text; gc.insert_date(orderNumber, outparcelno, 5, tax_breakdown, 1, DateTime.Now); // db.ExecuteQuery("insert into tax_breakdown_details (order_no, parcel_no,tax_authority,gross_tax,credit,net_tax) values ('" + orderNumber + "', '" + outparcelno + "', 'Total Tax','" + taxdetailrowTD[0].Text + "', '" + taxdetailrowTD[1].Text + "', '" + taxdetailrowTD[2].Text + "')"); } } b++; } if (l == 0) { gc.CreatePdf(orderNumber, outparcelnowoh, "Tax_HistoryDetailsPage", driver, "NV", "Washoe"); try { IWebElement newtable = driver.FindElement(By.XPath("//*[@id='534_" + pathid + " + 0']/div/table")); IList <IWebElement> newtableRow = newtable.FindElements(By.TagName("tr")); IList <IWebElement> newtablerowTD; int newtableRowcount = newtableRow.Count; foreach (IWebElement rowid1 in newtableRow) { newtablerowTD = rowid1.FindElements(By.TagName("td")); if (newtablerowTD.Count != 0 && !rowid1.Text.Contains("Authority")) { tax_breakdown = tax_breakdown = newtablerowTD[0].Text + "~" + newtablerowTD[1].Text + "~" + newtablerowTD[2].Text + "~" + newtablerowTD[3].Text + "~" + newtablerowTD[4].Text; gc.insert_date(orderNumber, outparcelno, 5, tax_breakdown, 1, DateTime.Now); //db.ExecuteQuery("insert into data_value_master (Order_no,parcel_no,Data_Field_Text_Id,Data_Field_value,Is_Table,Sequence) values ('" + orderNumber + "','" + outparcelno + "',5,'" + tax_breakdown + "',1,1)"); // db.ExecuteQuery("insert into tax_breakdown_details (order_no, parcel_no,tax_authority,net_rate,gross_tax,credit,net_tax) values ('" + orderNumber + "', '" + outparcelno + "', '" + newtablerowTD[0].Text + "', '" + newtablerowTD[1].Text + "', '" + newtablerowTD[2].Text + "', '" + newtablerowTD[3].Text + "', '" + newtablerowTD[4].Text + "')"); } } } catch { } for (int z = 300000; z <= 300070; z++) { string tableid = Convert.ToInt32(z).ToString(); string pathtdid = pathid + tableid; try { IWebElement commontable = driver.FindElement(By.XPath("//*[@id='534_" + pathtdid + "']/div/table")); IList <IWebElement> commontableRow = commontable.FindElements(By.TagName("tr")); IList <IWebElement> commontablerowTD; int commontableRowcount = commontableRow.Count; foreach (IWebElement rowid1 in commontableRow) { commontablerowTD = rowid1.FindElements(By.TagName("td")); if (commontablerowTD.Count != 0 && !rowid1.Text.Contains("Authority")) { tax_breakdown = commontablerowTD[0].Text + "~" + commontablerowTD[1].Text + "~" + commontablerowTD[2].Text + "~" + commontablerowTD[3].Text + "~" + commontablerowTD[4].Text; gc.insert_date(orderNumber, outparcelno, 5, tax_breakdown, 1, DateTime.Now); // db.ExecuteQuery("insert into data_value_master (Order_no,parcel_no,Data_Field_Text_Id,Data_Field_value,Is_Table,Sequence) values ('" + orderNumber + "','" + outparcelno + "',5,'" + tax_breakdown + "',1,1)"); //db.ExecuteQuery("insert into tax_breakdown_details (order_no, parcel_no,tax_authority,net_rate,gross_tax,credit,net_tax) values ('" + orderNumber + "', '" + outparcelno + "', '" + commontablerowTD[0].Text + "', '" + commontablerowTD[1].Text + "', '" + commontablerowTD[2].Text + "', '" + commontablerowTD[3].Text + "', '" + commontablerowTD[4].Text + "')"); } } } catch { } pathtdid = ""; } } l++; driver.Navigate().Back(); } TaxTime = DateTime.Now.ToString("HH:mm:ss"); // AMG Details string district_amgid = "-", amg_name = "-", status = "-", unbill_principal = "-", situs = "-", Legal_desc = "-", original_ass = "-", payoff = "-", due_desc = "-"; string curr_due_principal = "-", curr_due_interest = "-", curr_due_penalty = "-", curr_due_other = "-", curr_due_total_due = "-", amg_tax_authority = "-"; string ENI_principal = "-", ENI_interest = "-", ENI_penalty = "-", ENI_other = "-", ENI_total_due = "-"; string POB_Prepaid_principal = "-", POB_prepaid_interest = "-", POB_Prepay_Penalty = "-", POB_lien_reles = "-", POB_Curr_due = "-", POB_total_payoff = "-"; //string outparcelnowoh = "20808013"; // string outparcelnowoh = "03531041"; driver.Navigate().GoToUrl("https://www.amgnv.com/"); driver.FindElement(By.Name("Parcel")).SendKeys(outparcelnowoh); gc.CreatePdf(orderNumber, outparcelnowoh, "InputPassed_Amg_ParcelSearch", driver, "NV", "Washoe"); driver.FindElement(By.XPath("/html/body/table[3]/tbody/tr/td[6]/table/tbody/tr[2]/td[2]/p/table[2]/tbody/tr/td/table/tbody/tr[2]/td[1]/form/center/b/font/font/input")).SendKeys(Keys.Enter); Thread.Sleep(2000); gc.CreatePdf(orderNumber, outparcelnowoh, "Amg_MainPage", driver, "NV", "Washoe"); By amgfound = By.XPath("/html/body/table[3]/tbody/tr/td[6]/table/tbody/tr[2]/td[2]/p/table[2]/tbody/tr/td/b/font"); try { if (!Exists(amgfound)) { driver.FindElement(By.LinkText(outparcelnowoh)).SendKeys(Keys.Enter); Thread.Sleep(1000); gc.CreatePdf(orderNumber, outparcelnowoh, "Amg_DetailsPage", driver, "NV", "Washoe"); IWebElement amgdetailtable = driver.FindElement(By.XPath("/html/body/table[3]/tbody/tr/td[6]/table/tbody/tr[2]/td[2]/table[3]")); IList <IWebElement> amgdetailtableRow = amgdetailtable.FindElements(By.TagName("tr")); IList <IWebElement> amgdetailtablerowTD; foreach (IWebElement rowid1 in amgdetailtableRow) { amgdetailtablerowTD = rowid1.FindElements(By.TagName("td")); if (amgdetailtablerowTD.Count != 0 && !rowid1.Text.Contains("Parcel") && !rowid1.Text.Contains("Amounts")) { district_amgid = amgdetailtablerowTD[1].Text.Trim(); amg_name = amgdetailtablerowTD[2].Text.Trim(); unbill_principal = amgdetailtablerowTD[4].Text.Trim(); } } IWebElement situstable = driver.FindElement(By.XPath("/html/body/table[3]/tbody/tr/td[6]/table/tbody/tr[2]/td[2]/table[4]")); IList <IWebElement> situstableRow = situstable.FindElements(By.TagName("tr")); IList <IWebElement> situstablerowTD; int situsrowcount = situstableRow.Count; int s = 0; foreach (IWebElement rowid1 in situstableRow) { situstablerowTD = rowid1.FindElements(By.TagName("td")); if (situstablerowTD.Count != 0 && !rowid1.Text.Contains("Situs ") && s < situsrowcount - 1) { situs = situstablerowTD[0].Text.Replace(",", "").Trim(); original_ass = situstablerowTD[1].Text.Trim(); payoff = situstablerowTD[2].Text.Trim(); } if (s == situsrowcount - 1) { Legal_desc = situstablerowTD[0].Text.Trim(); } s++; } IWebElement duetable = driver.FindElement(By.XPath("/html/body/table[3]/tbody/tr/td[6]/table/tbody/tr[2]/td[2]/table[6]")); IList <IWebElement> duetableRow = duetable.FindElements(By.TagName("tr")); IList <IWebElement> duetablerowTD; int duerowcount = duetableRow.Count; int d = 0; foreach (IWebElement rowid1 in duetableRow) { duetablerowTD = rowid1.FindElements(By.TagName("td")); if (duetablerowTD.Count != 0 && !rowid1.Text.Contains("Principal") && d == 1) { curr_due_principal = duetablerowTD[1].Text.Trim(); curr_due_interest = duetablerowTD[2].Text.Trim(); curr_due_penalty = duetablerowTD[3].Text.Trim(); curr_due_other = duetablerowTD[4].Text.Trim(); curr_due_total_due = duetablerowTD[5].Text.Trim(); } if (d == 2) { ENI_principal = duetablerowTD[1].Text.Trim(); ENI_interest = duetablerowTD[2].Text.Trim(); ENI_penalty = duetablerowTD[3].Text.Trim(); ENI_other = duetablerowTD[4].Text.Trim(); ENI_total_due = duetablerowTD[5].Text.Trim(); } d++; } amg_tax_authority = driver.FindElement(By.XPath("/html/body/table[3]/tbody/tr/td[6]/table/tbody/tr[2]/td[2]/table[8]/tbody/tr[2]/td[2]/table/tbody/tr/td[2]")).Text; amg_tax_authority = amg_tax_authority.Replace("\n", ""); try { string currentHandle = driver.CurrentWindowHandle; IWebElement element = driver.FindElement(By.LinkText(payoff)); PopupWindowFinder finder = new PopupWindowFinder(driver); string popupWindowHandle = finder.Click(element); driver.SwitchTo().Window(popupWindowHandle); gc.CreatePdf(orderNumber, outparcelnowoh, "Amg_PayOffPage", driver, "NV", "Washoe"); IWebElement POBtable = driver.FindElement(By.XPath("/html/body/center/table[2]/tbody/tr/td/table")); IList <IWebElement> POBtableRow = POBtable.FindElements(By.TagName("tr")); //IList<IWebElement> POBtablerowTD; int POBrowcount = POBtableRow.Count; POB_Prepaid_principal = POBtableRow[1].Text.Replace("Prepaid Principal:", "").Trim(); POB_prepaid_interest = POBtableRow[2].Text.Replace("Prepaid Interest:", "").Trim(); POB_Prepay_Penalty = POBtableRow[3].Text.Replace("Prepayment Penalty:", "").Trim(); POB_lien_reles = POBtableRow[4].Text.Replace("Lien Release:", "").Trim();; POB_Curr_due = POBtableRow[5].Text.Replace("Current Due:", "").Trim(); POB_total_payoff = POBtableRow[6].Text.Replace("Total Payoff:", "").Trim(); string amgdetails = district_amgid + "~" + amg_name + "~" + situs + "~" + unbill_principal + "~" + Legal_desc + "~" + original_ass + "~" + payoff + "~" + curr_due_principal + "~" + curr_due_interest + "~" + curr_due_penalty + "~" + curr_due_other + "~" + curr_due_total_due + "~" + ENI_principal + "~" + ENI_interest + "~" + ENI_penalty + "~" + ENI_other + "~" + ENI_total_due + "~" + amg_tax_authority + "~" + POB_Prepaid_principal + "~" + POB_prepaid_interest + "~" + POB_Prepay_Penalty + "~" + POB_lien_reles + "~" + POB_Curr_due + "~" + POB_total_payoff; gc.insert_date(orderNumber, outparcelno, 6, amgdetails, 1, DateTime.Now); //db.ExecuteQuery("insert into data_value_master (Order_no,parcel_no,Data_Field_Text_Id,Data_Field_value,Is_Table,Sequence) values ('" + orderNumber + "','" + outparcelno + "',6,'" + amgdetails + "',1,1)"); // db.ExecuteQuery("insert into amg_details (order_no,parcel_no,District_amgid,Name,Situs,Unbill_prinicipal,Legaldescription,Original_Assesment,Payoff,curr_due_Principal,curr_due_Interest,curr_due_Penalty,curr_due_Other,curr_due_Total_Due,ENI_principal,ENI_interest,ENI_penalty,ENI_other,ENI_total_due,Tax_Authority,PayOff_Br_Prepaid_Principal,PayOff_Br_Prepaid_Interest,PayOff_Br_Prepayment_Penalty,PayOff_Br_Lien_Release,PayOff_Br_Current_Due,PayOff_Br_Total_Payoff) values ('" + orderNumber + "','" + parcelNumber + "','" + district_amgid + "','" + amg_name + "','" + situs + "','" + unbill_principal + "','" + Legal_desc + "','" + original_ass + "','" + payoff + "','" + curr_due_principal + "','" + curr_due_interest + "','" + curr_due_penalty + "','" + curr_due_other + "','" + curr_due_total_due + "','" + amg_tax_authority + "','" + ENI_principal + "','" + ENI_interest + "','" + ENI_penalty + "','" + ENI_other + "','" + ENI_total_due + "','" + POB_Prepaid_principal + "','" + POB_prepaid_interest + "','" + POB_Prepay_Penalty + "','" + POB_lien_reles + "','" + POB_Curr_due + "','" + POB_total_payoff + "')"); // Do whatever you need to on the popup browser, then... driver.Quit(); //driver.SwitchTo().Window(currentHandle); } catch { } } else { driver.Quit(); gc.mergpdf(orderNumber, "NV", "Washoe"); LastEndTime = DateTime.Now.ToString("HH:mm:ss"); gc.insert_TakenTime(orderNumber, "NV", "Washoe", StartTime, AssessmentTime, TaxTime, CitytaxTime, LastEndTime); return("Data Inserted Successfully"); } } catch { } LastEndTime = DateTime.Now.ToString("HH:mm:ss"); driver.Quit(); gc.insert_TakenTime(orderNumber, "NV", "Washoe", StartTime, AssessmentTime, TaxTime, CitytaxTime, LastEndTime); gc.mergpdf(orderNumber, "NV", "Washoe"); return("Data Inserted Successfully"); } catch (Exception ex) { driver.Quit(); GlobalClass.LogError(ex, orderNumber); throw ex; } } }
public ActionResult ImportAmazonPurchases(AmazonLoginViewModel amazonLoginViewModel) { var userId = User.Identity.GetUserId(); var folderName = $@"C:\EcommerceTracker\AmazonFiles\{userId}"; var chromeOptions = new ChromeOptions(); chromeOptions.AddUserProfilePreference("download.default_directory", folderName); chromeOptions.AddUserProfilePreference("intl.accept_languages", "nl"); chromeOptions.AddUserProfilePreference("disable-popup-blocking", "true"); // Amazon uses a captcha to prevent headless browsers from logging in // chromeOptions.AddArgument("--headless"); // TODO: Move to seperate method using (var driver = new ChromeDriver(chromeOptions)) { try { // Navigate to Order History Report page driver.Navigate().GoToUrl("https://www.amazon.com/gp/b2b/reports"); // Login to Amazon, with alternate login page detection // TODO: Check if username or password are incorrect var passwordFormFieldExists = driver.FindElementsById("ap_password").Count > 0; if (passwordFormFieldExists) { driver.FindElementById("ap_email").SendKeys(amazonLoginViewModel.EmailAddress); driver.FindElementById("ap_password").SendKeys(amazonLoginViewModel.Password); driver.FindElementById("signInSubmit").Click(); } else { driver.FindElementById("ap_email").SendKeys(amazonLoginViewModel.EmailAddress); driver.FindElementById("continue").Click(); driver.FindElementById("ap_password").SendKeys(amazonLoginViewModel.Password); driver.FindElementById("signInSubmit").Click(); } var waitForForm = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); waitForForm.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("report-form"))); // Look for existing reports // var generatedReportHistoryTableRows = driver.FindElementsByXPath("//*[@class='order-hist-submitted']/tbody/tr"); var startMonthSelect = new SelectElement(driver.FindElementById("report-month-start")); startMonthSelect.SelectByValue("1"); var startDaySelect = new SelectElement(driver.FindElementById("report-day-start")); startDaySelect.SelectByValue("1"); var startYearSelect = new SelectElement(driver.FindElementById("report-year-start")); startYearSelect.SelectByIndex(startYearSelect.Options.Count - 1); driver.FindElementById("report-use-today").Click(); driver.FindElementById("report-name").SendKeys("Generated for Ecommerce Tracker"); driver.FindElementById("report-confirm").Click(); var reportProcessed = false; var reportFailed = false; do { if (driver.FindElementsById("processing-report-table-row").Count < 1) { reportProcessed = true; } else if (driver.FindElementById("processing-long").Displayed) { driver.FindElementByXPath("//*[@id='report-refresh-button']/img").Click(); } else if (driver.FindElementById("processing-failed").Displayed) { reportFailed = true; } Thread.Sleep(TimeSpan.FromSeconds(3)); } while (!reportProcessed && !reportFailed); } catch (Exception e) { Debug.Write(e.Message); TempData["HTML"] = driver.PageSource; return(RedirectToAction("SeleniumError")); } } // TODO: Check if directory exists var fileNames = Directory.GetFiles(folderName); // TODO: Check if files exist var totalFileUploadResults = new FileUploadResultsViewModel { ExistingPurchases = _db.Purchases.Count(x => x.UserId == userId) }; var existingPurchaseFiles = _db.TrackedPurchaseFiles.Where(x => x.UserId == userId).ToList(); foreach (var fileName in fileNames) { if (existingPurchaseFiles.Select(x => x.FileName).Contains(fileName)) { continue; } var fileUploadResult = ImportAmazonFile(fileName); totalFileUploadResults.NewSites += fileUploadResult.NewSites; totalFileUploadResults.NewCategories += fileUploadResult.NewCategories; totalFileUploadResults.NewPurchases += fileUploadResult.NewPurchases; _db.TrackedPurchaseFiles.Add(new TrackedPurchaseFile { UserId = userId, FileName = fileName, FolderName = folderName, Website = "Amazon.com", ImportDate = DateTime.Now }); } _db.SaveChanges(); return(RedirectToAction("FileUploadResults", totalFileUploadResults)); }
public void DropDownSelectByValue(string value) { SelectElement dropDown = new SelectElement(control); dropDown.SelectByValue(value); }
// IWebDriver driver = new ChromeDriver(); static void Main(string[] args) { IWebDriver driver = new ChromeDriver(); //navigate rmr cloud url driver.Navigate().GoToUrl("https://www.hudsonbuscrm.com/login"); //demo message Task.Delay(5000).Wait(); //username ,pasword IWebElement username = driver.FindElement(By.Id("UserName")); IWebElement password = driver.FindElement(By.Id("Password")); //click login IWebElement btnlogin = driver.FindElement(By.Id("BtnLogin")); //login username.SendKeys("Administrator"); password.SendKeys("@AadGjMpTw9!"); btnlogin.Click(); Task.Delay(10000).Wait(); //load customer navigatiomn IWebElement LoadCustomer = driver.FindElement(By.Id("LoadCustomer1")); LoadCustomer.Click(); ////click Addcustomer button Task.Delay(10000).Wait(); IWebElement element5 = driver.FindElement(By.Id("AddNewCustomerList")); element5.Click(); Task.Delay(10002).Wait(); IWebElement element6 = driver.FindElement(By.Id("FirstName")); element6.SendKeys("Oindrila"); // Task.Delay(10003).Wait(); IWebElement element7 = driver.FindElement(By.Id("LastName")); element7.SendKeys("Khair"); //Task.Delay(10004).Wait(); IWebElement element8 = driver.FindElement(By.Id("BusinessName")); element8.SendKeys("Oindrila Khair"); //Task.Delay(10004).Wait(); IWebElement element9 = driver.FindElement(By.Id("DBA")); element9.SendKeys("abc"); //Task.Delay(10005).Wait(); IWebElement element10 = driver.FindElement(By.Id("PrimaryPhone")); element10.SendKeys("0178529584"); //Task.Delay(10005).Wait(); IWebElement element11 = driver.FindElement(By.Id("CellNo")); element11.SendKeys("3576819669"); //Task.Delay(10005).Wait(); IWebElement element12 = driver.FindElement(By.Id("EmailAddress")); element12.SendKeys("*****@*****.**"); // select the drop down list var LeadSource = driver.FindElement(By.Id("LeadSource")); //create select element object var selectElement = new SelectElement(LeadSource); //select by value selectElement.SelectByValue("New"); // select by text selectElement.SelectByText("New"); // select the drop down list var AccountOwner = driver.FindElement(By.Id("SoldBy")); //create select element object var selectElement1 = new SelectElement(AccountOwner); //select by value selectElement1.SelectByValue("62ae5767-2726-412b-8376-40ecd313374f"); // select by text selectElement1.SelectByText("Evan Islam"); // select the drop down list var Status = driver.FindElement(By.Id("Status")); //create select element object var selectElement2 = new SelectElement(Status); //select by value selectElement2.SelectByValue("Contacted"); // select by text selectElement2.SelectByText("Contacted"); //Task.Delay(10005).Wait(); IWebElement element13 = driver.FindElement(By.Id("AnnualRevenue")); element13.SendKeys("2000"); //Task.Delay(10005).Wait(); IWebElement element14 = driver.FindElement(By.Id("Website")); element14.SendKeys("owww.example.com"); // select the drop down list var Market = driver.FindElement(By.Id("Market")); //create select element object var selectElement3 = new SelectElement(Market); //select by value selectElement3.SelectByValue("ChildCare"); // select by text selectElement3.SelectByText("Child Care"); // Task.Delay(10005).Wait(); IWebElement element15 = driver.FindElement(By.Id("passengers")); element15.SendKeys("07"); Task.Delay(1000).Wait(); IWebElement element16 = driver.FindElement(By.ClassName("budget")); element16.SendKeys("7000"); Task.Delay(1000).Wait(); // select the drop down list var CustomerAccountType = driver.FindElement(By.Id("CustomerAccountType")); //create select element object var selectElement4 = new SelectElement(CustomerAccountType); //select by value selectElement4.SelectByValue("Vendor"); // select by text selectElement4.SelectByText("Vendor"); // select the drop down list var PreferredContactMethod = driver.FindElement(By.Id("PreferredContactMethod")); //create select element object var selectElement5 = new SelectElement(PreferredContactMethod); //select by value selectElement5.SelectByValue("Work"); // select by text selectElement5.SelectByText("Work"); //Task.Delay(10001).Wait(); IWebElement element17 = driver.FindElement(By.Id("Note")); element17.SendKeys("Hello"); //Task.Delay(10001).Wait(); IWebElement element18 = driver.FindElement(By.Id("Street")); element18.SendKeys("930 Neuport Lane"); //Task.Delay(10001).Wait(); IWebElement element19 = driver.FindElement(By.Id("City")); element19.SendKeys("Alpharetta"); //Task.Delay(10001).Wait(); IWebElement element20 = driver.FindElement(By.Id("State")); element20.SendKeys("GA"); //Task.Delay(10001).Wait(); IWebElement element21 = driver.FindElement(By.Id("ZipCode")); element21.SendKeys("30201"); //Task.Delay(50002).Wait(); IWebElement save = driver.FindElement(By.Id("SaveCustomer")); save.Click(); }
public void SelectOperation(Operation operation) { var select = new SelectElement(OperationSelect); select.SelectByValue(operation.GetDescription()); }
public void SelectOrderDropDown(string option) { var selectElement = new SelectElement(OrderList); selectElement.SelectByValue(option); }
// [TestMethod, TestCategory("Smoke")] //public void RegisterAccount() //above chnages to "LoginPage" below as a //result of the return at the buttom public LoginPage RegisterAccount() { //click on register button var registerButton = Driver.FindElement(By.ClassName("ico-register")); registerButton.Click(); //Assert register page is displayed var registerPage = Driver.Title; Assert.AreEqual(registerPage, "nopCommerce demo store. Register"); // click Gender var maleGender = Driver.FindElement(By.Id("gender-male")); maleGender.Click(); //enter firstname var firstName = Driver.FindElement(By.Id("FirstName")); firstName.SendKeys("Dejo"); //enter lastname var lastName = Driver.FindElement(By.Id("LastName")); lastName.SendKeys("Akin"); //select day of Birth var dayOfBirth = Driver.FindElement(By.Name("DateOfBirthDay")); var selectDayOfBirth = new SelectElement(dayOfBirth); selectDayOfBirth.SelectByIndex(5);//you are counting from the //dates //select Month of Birth var monthOfBirth = Driver.FindElement(By.Name("DateOfBirthMonth")); var selectMonthOfBirth = new SelectElement(monthOfBirth); selectMonthOfBirth.SelectByValue("6");//use"6" bcos it is a string //select year of Birth var yearOfBirth = Driver.FindElement(By.Name("DateOfBirthYear")); var selectYearOfBirth = new SelectElement(yearOfBirth); selectYearOfBirth.SelectByText("1980"); //enter email var email = Driver.FindElement(By.Id("Email")); email.SendKeys("*****@*****.**"); //tick newsletter checkbox var newsletterBox = Driver.FindElement(By.Id("Newsletter")); /** * This code below would be standard if the checkbox * for newsletter was never ticked by default */ if (!newsletterBox.Selected) { newsletterBox.Click(); } //enter password var password = Driver.FindElement(By.Id("Password")); password.SendKeys("welcome123"); //confirm password var passwordConfirm = Driver.FindElement(By.Id("ConfirmPassword")); passwordConfirm.SendKeys("welcome123"); //click register button var creatAccountButton = Driver.FindElement(By.Id("register-button")); creatAccountButton.Click(); Thread.Sleep(3000); return(new LoginPage(Driver)); }
public void Action_SelectOptionByValue(string value) { SelectElement selectedElementObj = new SelectElement(_selectedElementItem.refElement); if (selectedElementObj != null) selectedElementObj.SelectByValue(value); }
public static void SelectByValue(this IWebElement element, string text, string elementName) { SelectElement oSelect = new SelectElement(element); oSelect.SelectByValue(text); }