コード例 #1
0
        public void RunElementAction()
        {
            // Create Action
            var action = new TypeRandomPhoneAction();

            // Prepare state
            driver.FindElement(By.Id("name")).SendKeys("John Smith");
            driver.FindElement(By.Id("password")).SendKeys("12345");
            driver.FindElement(By.Id("login")).Click();
            driver.HideKeyboard();

            // Set action parameters
            action.countryCode = "1";
            action.maxDigits   = 8;

            // Run action
            runner.Run(action, By.Id("phone"));
        }
コード例 #2
0
        public ExecutionResult Execute(WebTestHelper helper)
        {
            // Get driver initialized by TestProject Agent
            // No need to specify browser type, it can be done later via UI
            var          driver = helper.Driver;
            TestReporter report = helper.Reporter;

            // Navigate to TestProject Demo website
            driver.Navigate().GoToUrl("https://example.testproject.io/web/");

            // Initialize the properties of the LoginPage with the driver
            var loginPage = PageFactory.InitElements <LoginPage>(driver);

            report.Step("Navigated to TestProject Demo", loginPage.Displayed);

            // Login using provided credentials
            loginPage.Login(name, password);

            // Initialize the properties of the profilePage with the driver
            var profilePage = PageFactory.InitElements <ProfilePage>(driver);

            report.Step($"Logged in with {name}:{password}", profilePage.Displayed);

            profilePage.SelectCountry(country);
            profilePage.TypeAddress(address);
            profilePage.TypeEmail(email);

            // Type random phone number using Addon proxy
            var             actionProxy = new TypeRandomPhoneAction("1", 7);
            ExecutionResult result      = helper.ExecuteProxy(actionProxy, profilePage.GetPhoneElement());

            report.Step("Type random phone number using Addon proxy", result == ExecutionResult.Passed);

            // Save profile
            profilePage.Save();
            report.Step("Profile information saved", profilePage.Saved, TakeScreenshotConditionType.Always);

            report.Result = "Test completed successfully";
            return(profilePage.Saved ? ExecutionResult.Passed : ExecutionResult.Failed);
        }
コード例 #3
0
        public static void RunElementAction(Runner runner)
        {
            // Create Action
            var action = new TypeRandomPhoneAction();

            // Prepare state
            var driver = (WebDriver)runner.GetDriver();

            driver.Navigate().GoToUrl("https://example.testproject.io/web/");

            driver.FindElement(By.Id("name")).SendKeys(name);
            driver.FindElement(By.Id("password")).SendKeys(password);
            driver.FindElement(By.Id("login")).Click();

            // Set action parameters
            action.countryCode = "1";
            action.maxDigits   = 8;

            // Run action
            runner.Run(action, By.Id("phone"));

            Thread.Sleep(1000);
        }
コード例 #4
0
        static void RunElementAction(Runner runner)
        {
            // Create Action
            var action = new TypeRandomPhoneAction();

            // Get the Driver
            var driver = (IOSDriver <IOSElement>)runner.GetDriver();

            // Prepare the App
            driver.ResetApp();

            // Prepare state
            driver.FindElement(By.Id("name")).SendKeys("John Smith");
            driver.FindElement(By.Id("password")).SendKeys("12345");
            driver.FindElement(By.Id("login")).Click();
            driver.HideKeyboard();

            // Set action parameters
            action.countryCode = "1";
            action.maxDigits   = 8;

            // Run action
            runner.Run(action, By.Id("phone"));
        }