static void SelectValue(ChromiumDriver driver, string targetId, string targetValue) { var education = driver.FindElementById(targetId); var selectElement = new SelectElement(education); //select by value selectElement.SelectByValue(targetValue); }
public static void FillText(ChromiumDriver driver, List <FormData> formDataList, string formElemTemp) { foreach (FormData fv in formDataList) { var elemId = String.Format(formElemTemp, fv.Id); Boolean isElemEmpty = driver.FindElement(By.Id(elemId)).Size.IsEmpty; if (isElemEmpty) { Common.ScrollVerticalByPixel(driver, 300); } if (fv.ControlTypeId == ControlType.Select) { Common.SelectValue(driver, elemId, fv.Text); } else if (fv.ControlTypeId == ControlType.Button) { Actions action = new Actions(driver); var el = driver.FindElementById(elemId); Common.ScrollPageDown(el); action.MoveToElement(el).Click().Perform(); } else { Common.EnterText(driver, elemId, fv.Text); } if (fv.IsTab) { driver.FindElement(By.Id(elemId)).SendKeys(Keys.Tab); Thread.Sleep(2000); //check } Thread.Sleep(500); } }
public static void EnterText(ChromiumDriver driver, string id, string txt) { driver.FindElementById(id).SendKeys(txt); Thread.Sleep(3000); }