//Navigati catre pagina https://demoqa.com/automation-practice-form. Completati TOATE campurile si apasati pe butonul de Submit. public void AutomationPracticeFormExercise() { //Arrange NavigateToUrl("https://demoqa.com/automation-practice-form"); //Act DemoQaFormPage demoQaFormPage = new DemoQaFormPage(Driver); var myUser = new DemoQaUserDetailsDto { FirstName = "Test First Name", LastName = "Test Last Name", Email = "*****@*****.**", Gender = "Female", MobilePhone = "4123456789", DateOfBirth = "03/12/1970", Subjects = "Maths, Arts, English", Hobbies = "Sports, Music", PictureName = "test-img.JPG", CurrentAddress = "My current street 11, BV, RO", State = "Haryana", City = "Panipat" }; demoQaFormPage.FillInForm(myUser); demoQaFormPage.SubmitForm(); //Assert Assert.AreEqual("Thanks for submitting the form", demoQaFormPage.ConfirmationDialogTitle.Text); }
public void FillInForm(DemoQaUserDetailsDto user) { var FirstNameValue = user.GetType().GetRuntimeProperty("FirstName").GetValue(user); if (FirstNameValue != null) { FirstNameFieldTextBox.SendKeys(FirstNameValue.ToString()); } var LastNameValue = user.GetType().GetRuntimeProperty("LastName").GetValue(user); if (LastNameValue != null) { LastNameFieldTextBox.SendKeys(LastNameValue.ToString()); } var EmailValue = user.GetType().GetRuntimeProperty("Email").GetValue(user); if (EmailValue != null) { EmailFieldTextBox.SendKeys(EmailValue.ToString()); } var GenderValue = user.GetType().GetRuntimeProperty("Gender").GetValue(user); if (GenderValue != null) { _driver.FindElement(By.XPath($"//label[text()='{GenderValue}']")).Click(); } var MobilePhoneValue = user.GetType().GetRuntimeProperty("MobilePhone").GetValue(user); if (MobilePhoneValue != null) { MobileFieldTextBox.SendKeys(MobilePhoneValue.ToString()); } var DateOfBirthValue = user.GetType().GetRuntimeProperty("DateOfBirth").GetValue(user); if (DateOfBirthValue != null) { var dob = DateOfBirthValue.ToString().Split('/').ToList(); SelectDateOfBirth(dob[0], dob[1], dob[2]); } var SubjectsValue = user.GetType().GetRuntimeProperty("Subjects").GetValue(user); if (SubjectsValue != null) { var subjects = SubjectsValue.ToString().Split(',').ToList(); foreach (var subject in subjects) { SelectSubject(subject); } } var HobbiesValue = user.GetType().GetRuntimeProperty("Hobbies").GetValue(user); if (HobbiesValue != null) { var hobbies = HobbiesValue.ToString().Split(',').ToList(); foreach (var hobby in hobbies) { _driver.FindElement(By.XPath($"//label[text()='{hobby.Trim()}']")).Click(); } } var PictureNameValue = user.GetType().GetRuntimeProperty("PictureName").GetValue(user); if (PictureNameValue != null) { var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); ChooseFileButton.SendKeys($"{path}\\Resources\\{PictureNameValue}"); } var CurrentAddressValue = user.GetType().GetRuntimeProperty("CurrentAddress").GetValue(user); if (CurrentAddressValue != null) { CurrentAddressFieldTextBox.SendKeys(CurrentAddressValue.ToString()); } var StateValue = user.GetType().GetRuntimeProperty("State").GetValue(user); if (StateValue != null) { Helper.ScrollElementIntoView(_driver, StateDropdown); SelectFromDropdown(StateDropdown, StateValue.ToString()); } var CityValue = user.GetType().GetRuntimeProperty("City").GetValue(user); if (CityValue != null) { SelectFromDropdown(CityDropdown, CityValue.ToString()); } }