public async Task <BrowserResult> InvokeAsync(BrowserOptions options, CancellationToken cancellationToken = new CancellationToken())
        {
            if (options == null)
            {
                throw new ArgumentException("Options cannot be null", nameof(options));
            }

            using var listener = new LoopbackHttpListener(Port, _path);
            OpenBrowser.OpenBrowser(options.StartUrl, UserName, Password);

            try
            {
                var result = await listener.WaitForCallbackAsync().ConfigureAwait(false);

                if (string.IsNullOrWhiteSpace(result))
                {
                    return(new BrowserResult {
                        ResultType = BrowserResultType.UnknownError, Error = "Empty response."
                    });
                }

                return(new BrowserResult {
                    Response = result, ResultType = BrowserResultType.Success
                });
            }
            catch (TaskCanceledException ex)
            {
                return(new BrowserResult {
                    ResultType = BrowserResultType.Timeout, Error = ex.Message
                });
            }
        }
 /// <summary>
 /// Adds a test step if there is a url to navigate to.
 /// </summary>
 /// <param name="url">the url to navigate to.</param>
 private void CheckPageNavigation(string url)
 {
     if (url != string.Empty)
     {
         TestStep testStep = new OpenBrowser();
         testStep.Arguments.Add("value", url);
         this.testStepQueue.Enqueue(testStep);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AboutViewModel"/> class.
 /// </summary>
 /// <param name="mainThreadScheduler">The scheduler to use for processing on the main UI thread.</param>
 /// <param name="taskPoolScheduler">The scheduler to use for scheduling on a background thread.</param>
 /// <param name="hostScreen">The main screen for routing.</param>
 public AboutViewModel(
     IScheduler mainThreadScheduler = null,
     IScheduler taskPoolScheduler   = null,
     IScreen hostScreen             = null)
     : base("About", mainThreadScheduler, taskPoolScheduler, hostScreen)
 {
     ShowIconCredits = ReactiveCommand.CreateFromObservable <string, Unit>(url => OpenBrowser.Handle(url));
     ShowIconCredits.Subscribe();
 }
 public Fitness_Subscription(OpenBrowser methods)
 {
     _test = methods;
 }
Beispiel #5
0
        private void validLoginTestScript(int configIndex)
        {
            // Configuration Variables
            string selectedBrowser = configDatatables["DriverConfig"].Rows[configIndex]["Browser"].ToString();
            string environment     = configDatatables["DriverConfig"].Rows[configIndex]["Environment"].ToString();

            // Initialize variables
            IList <string> testLog = new List <string>();
            OpenBrowser    browser;
            string         testLogName;
            string         testLogPath;
            string         userType;
            bool           testPassed;
            LoginPage      loginPage;
            HomePage       homePage;

            // For each row in the "ValidLogin" sheet...
            for (int x = 0; x < dataDatatables["ValidLogin"].Rows.Count; x++)
            {
                // Initialize variables for this test
                testLog.Clear();
                testPassed  = true;
                testLogName = selectedBrowser.ToLower() + "_" + "ValidLoginTest" + "_Row" + (x + 2) + ".txt";
                string logTitle = "------------------ " + selectedBrowser.ToLower() + " \"Valid Login\" test - Row " + (x + 2) + " ------------------";
                testLog.Add(logTitle);

                // Fetch test data
                testLog.Add("Fetching test data...");
                userType = dataDatatables["ValidLogin"].Rows[x]["User"].ToString();

                // Open browser
                browser = new OpenBrowser(environment, selectedBrowser, @"Drivers");

                // Create an instance of LoginPage and wait for it to load
                loginPage = new LoginPage(browser.Driver);

                // Set Username, Password and click on selected button.
                if (loginPage.login(Users[userType].Username, Users[userType].Password, testLog))
                {
                    testLog.Add("Login steps completed for " + userType + " user.");
                }
                else
                {
                    testLog.Add("Login steps failed for " + userType + " user.");
                    testPassed = false;
                }

                // Load Home page instance and wait for it to finish loading.
                homePage = new HomePage(browser.Driver);

                // Wait for loading spinner to appear and disappear
                if (!sharedFunctions.waitForObject(homePage.spinner, 1000, 10000))
                {
                    testPassed = false;
                }
                if (!sharedFunctions.waitForObjectDisappears(homePage.spinner, 1000, 10000))
                {
                    testPassed = false;
                }

                // Close Browser
                browser.Driver.Close();
                browser.Driver.Quit();

                // Delete old testLogs
                testLogPath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDi‌​rectory, @".\TestLogs\"));
                if (!Directory.Exists(testLogPath))
                {
                    Directory.CreateDirectory(testLogPath);
                }
                sharedFunctions.deleteTestLogs(testLogPath, testLogName);

                // Add the passed or failed tag to the log file
                testLogName  = testPassed ? "Passed_" + testLogName : testLogName = "Failed_" + testLogName;
                testLogPath += testLogName;

                // Save test log in the corresponding text file
                TextWriter textWriter = new StreamWriter(testLogPath, false);
                foreach (string entry in testLog)
                {
                    textWriter.WriteLine(entry);
                }
                textWriter.Close();

                // Assertion for this individual test
                Assert.IsTrue(testPassed);
            }
        }
Beispiel #6
0
 public void setup()
 {
     _test = new OpenBrowser();
     _fs   = new Fitness_Subscription(_test);
 }