Beispiel #1
0
        public void should_be_able_to_click_on_elements_with_text()
        {
            //Initialize MvcPages
            var browserAdapterConfig = BrowserAdapterConfig.FromAppConfig(TestContext.CurrentContext.TestDirectory);

            browserAdapterConfig.MeasureEndpointCoverage      = true;
            browserAdapterConfig.AvailableEndpointsAssemblies = new List <Assembly>()
            {
                typeof(HomeController).Assembly
            };
            //Prepare infrastructure for test
            using (var browserAdapter = BrowserAdapter.Create(browserAdapterConfig))
            {
                //Test
                browserAdapter.NavigateTo <HomeController>(c => c.Index());


                browserAdapter.ReloadPageWith(() => browserAdapter.ClickOnElementWithText("Register"));

                var registerForm = browserAdapter.GetForm <RegisterViewModel>("RegisterForm");
                registerForm.ClickOnElementWithText("Więcej");
                Assert.DoesNotThrow(() => registerForm.ClickOnElementWithText("Register"));
            }
        }
Beispiel #2
0
        //[TestCase(BrowserType.InternetExplorer)]
        public void should_be_able_to_fill_sample_form(BrowserType driverType)
        {
            //Initialize MvcPages
            var browserAdapterConfig = new BrowserAdapterConfig()
            {
                BrowserType          = driverType,
                SeleniumDriversPath  = Path.Combine(TestContext.CurrentContext.TestDirectory, "Drivers"),
                PageUrl              = "http://*****:*****@"c:\selenium\",
                BrowserDimensions    = new BrowserDimensionsConfig
                {
                    Width  = 1200,
                    Height = 768
                },
                BrowserCameraConfig = new BrowserCameraConfig
                {
                    LensType = LensType.Regular
                }
            };

            //Initialize VisualAssertions
            AssertView.Init(new VisualAssertionsConfig
            {
                BrowserName        = driverType.ToString(),
                ProjectName        = "Sample Project",
                ScreenshotCategory = "Sample Form",
                ProcessScreenshotsAsynchronously = true
            });


            //Prepare infrastructure for test
            using (var browserAdapter = BrowserAdapter.Create(browserAdapterConfig))
            {
                //Test
                browserAdapter.NavigateTo <TestFormsController>(c => c.Index());
                AssertView.EqualsToPattern(browserAdapter, "Sample11");

                var detinationForm = browserAdapter.GetForm <SampleFormViewModel>(FormsIds.TestFormDst);
                var sourcenForm    = browserAdapter.GetForm <SampleFormViewModel>(FormsIds.TestFormSrc);

                AssertView.EqualsToPattern(detinationForm, "Destination form");
                AssertView.EqualsToPattern(sourcenForm, "Source form");

                var textInputValue = sourcenForm.GetFieldValue(x => x.TextInput);
                detinationForm.SetFieldValue(x => x.TextInput, textInputValue);

                var textAreaValue = sourcenForm.GetFieldValue(x => x.TextAreaInput);
                detinationForm.SetFieldValue(x => x.TextAreaInput, textAreaValue);

                var passwordValue = sourcenForm.GetFieldValue(x => x.PasswordInput);
                detinationForm.SetFieldValue(x => x.PasswordInput, passwordValue);


                var checkboxValue = sourcenForm.GetFieldValue(x => x.CheckboxInput);
                detinationForm.SetFieldValue(x => x.CheckboxInput, checkboxValue);

                var selectListValue = sourcenForm.GetFieldValue(x => x.SelectListValue);
                detinationForm.SetFieldValue(x => x.SelectListValue, selectListValue);

                var multiselectListValue = sourcenForm.GetFieldValue(x => x.MultiSelectListValue);
                detinationForm.SetFieldValue(x => x.MultiSelectListValue, multiselectListValue);

                AssertView.EqualsToPattern(browserAdapter, "Sample12");

                detinationForm.SetFieldValue("SingleFile", "SampleFileToUpload.docx");
            }
        }
 public PageAdapter(BrowserAdapter <T> browser)
 {
     _browser = browser;
     _driver  = browser.Driver;
 }
 public void SetCookie(string name, string value)
 {
     BrowserAdapter.SetCookie(name, value);
 }
 public void ClearCookies()
 {
     BrowserAdapter.ClearCookies();
 }
Beispiel #6
0
 public JavaScriptAdapter(BrowserAdapter <T> browser)
 {
     _browser = browser;
     _driver  = browser.Driver;
     _js      = (IJavaScriptExecutor)_driver;
 }