Beispiel #1
0
        public override void InitialDisplay()
        {
            System.Diagnostics.Trace.WriteLine($"Web browser initial display");
            var wv2 = new BrowserWebView2();

            wv2.LoadResult += (res) =>          // asynchronous to start up, UCTG, etc, winforms needs to run
            {
                System.Diagnostics.Trace.WriteLine($"Web browser view returned {res}");
                if (res == true)
                {
                    wbb = wv2;
                }
                else
                {
                    extButtonIE11Warning.Visible = true;
                    wbb = new BrowserIE11();
                }

                wbb.urlallowed      = urlallowed;
                wbb.userurllist     = GetSetting("Allowed", "");
                wbb.webbrowser.Dock = DockStyle.Fill;
                Controls.Add(wbb.webbrowser);
                Controls.SetChildIndex(wbb.webbrowser, 0);

                last_sys_tracked = uctg.GetCurrentHistoryEntry?.System;
                PresentSystem(last_sys_tracked);    // may be null
            };
            wv2.Start();
        }
 public static async Task Cleanup()
 {
     if (BrowserBase == null)
     {
         return;
     }
     await BrowserBase.CloseAsync();
 }
Beispiel #3
0
        public MainPage OpenMainInBrowser(DriverType driverType)
        {
            _browser = new BrowserBase(driverType);
            _driver  = _browser.GetDriver();
            var url = _appConfiguration.GetApplicationConfigurationValue(ConfigurationEnums.RegistrationUrl);

            _driver.Navigate().GoToUrl(url);
            return(this);
        }
        public void GivenNavigateToWebApiPostsInBrowser(string driverType)
        {
            var browserType = (DriverType)Enum.Parse(typeof(DriverType), driverType);

            _browser = new BrowserBase(browserType);
            _driver  = _browser.GetDriver();
            _driver.Navigate().GoToUrl(_url);
            Log.Info("Navigating to " + _url);
            Assert.AreEqual(_driver.Url, "https://jsonplaceholder.typicode.com/posts");
        }
        public void OpenLoginPageInBrowser(DriverType driverType)
        {
            _browser = new BrowserBase(driverType);
            _driver  = _browser.GetDriver();
            var url      = _appConfiguration.GetApplicationConfigurationValue(ConfigurationEnums.RegistrationUrl);
            var endpoint = url + PageName;

            Log.Info($"Navigating to {endpoint}");
            _driver.Navigate().GoToUrl(endpoint);
        }
        public override void ClickOperation(string elementName)
        {
            string trimmedElementName = elementName.Replace(" ", string.Empty).Trim();

            switch (trimmedElementName.ToUpper())
            {
            case "ADDTOCART":
                TshirtImg.MoveToElementByAction(BrowserBase);
                AddToCartBtn.ClickOnElement();
                break;

            case "PROCEEDTOCHECKOUT":
                BrowserBase.WaitForElementToBeClickable(ProceedToCheckOutBtn, 20);
                ProceedToCheckOutBtn.ClickOnElement();
                break;
            }
        }
        public static async Task Initialize()
        {
            if (BrowserBase != null)
            {
                await BrowserBase.CloseAsync();
            }
            await DownloadBrowser();

            BrowserBase = await Puppeteer.LaunchAsync(new LaunchOptions
            {
                Headless        = false,
                Args            = new[] { "--start-maximized" },
                DefaultViewport = null,
                Timeout         = 10000
            });

            PageBase = await BrowserBase.NewPageAsync();

            PageBase.DefaultNavigationTimeout = (int)TimeSpan.FromSeconds(15).TotalMilliseconds;
        }
Beispiel #8
0
        /// <summary>
        /// Method to verify & click the Order Reference Number
        /// </summary>
        /// <returns></returns>
        public bool CheckForOrderReference()
        {
            bool orderMatched             = false;
            IList <IWebElement> tableRows =
                BrowserBase.GetListOfWebElements(By.XPath("//*[@id = 'order-list']/tbody/tr/td[1]"));

            if (tableRows.Count > 0)
            {
                for (int i = 0; i < tableRows.Count; i++)
                {
                    string orderRef = tableRows[i].Text.Trim();
                    if (orderRef.Equals(BrowserBase.OrderNumber))
                    {
                        orderMatched = true;
                        tableRows[i].ClickOnElement();
                        break;
                    }
                }
            }
            return(orderMatched);
        }
 public Tshirts(BrowserBase browserBase) : base(browserBase)
 {
 }
Beispiel #10
0
        public void GivenINavigateToPurplebricksHomePageOnASystemWithConfiguration(string configuration)
        {
            BrowserBase Launch = new BrowserBase();

            Launch.OpenApplication(configuration);
        }
Beispiel #11
0
 public OrderHistory(BrowserBase browser) : base(browser)
 {
 }
Beispiel #12
0
 /// <summary>
 ///  Method to check for Order Status Step by Step Label displayed or not
 /// </summary>
 /// <returns></returns>
 public bool IsStatusDisplayed()
 {
     BrowserBase.WaitForElementToBeVisible(By.XPath("//*[@id='block-order-detail']/h1"));
     return(OrderStatusStepByStepLbl.IsDisplayed());
 }
 public override bool CheckForPageLoad()
 {
     return(BrowserBase.WaitForElementToBeVisible(By.XPath("//*[@id='center_column']/div/h1")));
 }
Beispiel #14
0
 /// <summary>
 /// Method to check for PageLoad / Sync
 /// </summary>
 /// <returns> bool </returns>
 public override bool CheckForPageLoad()
 {
     return(BrowserBase.WaitForElementToBeVisible(By.XPath("//*[text() = 'Authentication']"), 20));
 }
Beispiel #15
0
 public ShoppingCartSummary(BrowserBase browser) : base(browser)
 {
 }
 public override bool CheckForPageLoad()
 {
     return(BrowserBase.WaitForElementToBeVisible(
                By.XPath("//*[text() = 'Your order on My Store is complete.']")));
 }
 public MyAccount(BrowserBase browserBase) : base(browserBase)
 {
 }
 public OrderConfirmation(BrowserBase browser) : base(browser)
 {
 }
Beispiel #19
0
        public void ExecuteTest(BrowserBase browser, Test test)
        {
            var testResult = new TestResult
            {
                TestName       = test.Name,
                CollectionName = test.CollectionName,
                Url            = test.TestUrl,
                DriverType     = browser.DriverType,
            };

            var traceResult = new StringBuilder();

            traceResult.AppendLine("Collection: " + test.CollectionName);
            traceResult.AppendLine("Name: " + test.Name);
            traceResult.AppendLine("Url: " + test.TestUrl);

            try
            {
                browser.Driver.Url = test.TestUrl;

                // Hack, sometimes the set does not work?
                if (browser.Driver.Url == AboutBlank)
                {
                    browser.Driver.Url = test.TestUrl;
                }

                dynamic context = new ExpandoObject();
                context.DriverType = browser.DriverType;

                for (var i = 0; i < test.Commands.Count; i++)
                {
                    var command = test.Commands[i];
                    Thread.Sleep(100);

                    try
                    {
                        command.Execute(browser.Driver, context);
                    }
                    catch (Exception ex)
                    {
                        string commandJson;
                        try
                        {
                            commandJson = JsonConvert.SerializeObject(
                                command,
                                Formatting.Indented,
                                new JsonSerializerSettings {
                                DefaultValueHandling = DefaultValueHandling.Ignore
                            }
                                );
                        }
                        catch (Exception serializeEx)
                        {
                            commandJson = "Unable to serialize command: " + serializeEx.Message;
                        }
                        var message = String.Format("Test: {0}, Command #{1}: {2}{3}Command Config:{3}{4}{3}{5}",
                                                    test.Name,
                                                    i + 1,
                                                    command.Name,
                                                    Environment.NewLine,
                                                    commandJson,
                                                    ex.Message);
                        throw new Exception(message, ex);
                    }
                }

                testResult.Status = ResultStatus.Passed;
                traceResult.AppendLine("Success");
            }
            catch
            {
                testResult.Status = ResultStatus.Failed;
                traceResult.AppendLine(String.Empty);
                traceResult.AppendLine("***** FAILURE *****");
                throw;
            }
            finally
            {
                traceResult.AppendLine(String.Empty);
                traceResult.AppendLine("------------------------------------------------------------------------");

                testResult.TraceResult = traceResult.ToString();

                var testResultJson = JsonConvert.SerializeObject(testResult);
                Trace.WriteLine(testResultJson);
            }
        }
 public Address(BrowserBase browser) : base(browser)
 {
 }
 public override bool CheckForPageLoad()
 {
     return(BrowserBase != null && BrowserBase.WaitForElementToBeVisible(By.XPath("//span[@class = 'cat-name']"), 20));
 }
 public OrderSummary(BrowserBase browser) : base(browser)
 {
 }
Beispiel #23
0
 public Shipping(BrowserBase browser) : base(browser)
 {
 }
Beispiel #24
0
 public Authentication(BrowserBase browserBase) : base(browserBase)
 {
 }
 public override bool CheckForPageLoad()
 {
     return(BrowserBase != null && BrowserBase.WaitForElementToBeVisible(By.XPath("//*[@id='block_top_menu']/ul/li[3]/a"), 20));
 }
Beispiel #26
0
 public override bool CheckForPageLoad()
 {
     return(BrowserBase.WaitForElementToBeVisible(By.XPath("//h1[text() = 'Shipping']")));
 }
 public StepDefinition(BrowserBase browserBase) => _browserBase = browserBase;
 public YourPersonalInformation(BrowserBase browser) : base(browser)
 {
 }
Beispiel #29
0
 public override bool CheckForPageLoad()
 {
     return(BrowserBase.WaitForElementToBeVisible(By.Id("cart_title")));
 }
 public override bool CheckForPageLoad()
 {
     return(BrowserBase.WaitForElementToBeVisible(
                By.XPath("//h1[text() = 'Please choose your payment method']")));
 }