Esempio n. 1
0
        private void ExtractUpdatePanelNamesFromAsyncPostback(string body, WebTestContext context)
        {
            RuleHelper.NotAlreadyDone(context, "$UPDATEPANEL.EXTRACTED", () =>
            {
                int newUpdatePanelsAdded = 0;
                foreach (Match match in _FindUpdatePanelRegex.Matches(body))
                {
                    string updatePanelDivID      = match.Groups["name"].Value;
                    string updatePanelFullId     = updatePanelDivID.Replace('_', '$');
                    string updatePanelIdLastPart = updatePanelFullId.Substring(updatePanelFullId.LastIndexOf('$') + 1);

                    string contextKeyName = UPDATE_PANEL_PREFIX + updatePanelIdLastPart;
                    string keyName        = RuleHelper.PlaceUniqueItem(context, contextKeyName, updatePanelFullId);

                    int countOfKeys = context.Count;
                    RuleHelper.PlaceUniqueItem(context, UPDATE_PANEL_KEY, updatePanelFullId);
                    if (context.Count > countOfKeys)
                    {
                        newUpdatePanelsAdded++;
                    }
                }

                context[UPDATE_PANEL_COUNT_KEY] = ((int)context[UPDATE_PANEL_COUNT_KEY]) + newUpdatePanelsAdded;
            });
        }
 public void RunningATestCreatesLogFileByDefault()
 {
     System.Console.WriteLine($"Thread used in test: {Thread.CurrentThread.ManagedThreadId}");
     TestLogs.Attach();
     Assert.True(File.Exists(WebTestContext.Get <string>(Constants.TestLogFileKey)), "Test Log file not found.");
     logfile = WebTestContext.Get <string>(Constants.TestLogFileKey);
 }
Esempio n. 3
0
 private void ProcessObject(object obj, string keyName, WebTestContext context)
 {
     if (obj is ArrayList)
     {
         ArrayList list    = obj as ArrayList;
         int       counter = 1;
         foreach (object o in list)
         {
             string keyNameWithIndex = keyName + "." + counter++;
             ProcessObject(o, keyNameWithIndex, context);
         }
     }
     else if (obj is Hashtable)
     {
         Hashtable table = obj as Hashtable;
         foreach (DictionaryEntry entry in table)
         {
             string keyNameWithProperty = keyName + "." + entry.Key;
             ProcessObject(entry.Value, keyNameWithProperty, context);
         }
     }
     else
     {
         context[keyName] = obj;
     }
 }
 public void CreateAndAttachScreenshotPasses()
 {
     System.Console.WriteLine($"Thread used in test: {Thread.CurrentThread.ManagedThreadId}");
     Screenshot.Attach();
     Assert.True(File.Exists(WebTestContext.Get <string>(Constants.ScreenshotFileKey)), "Screenshot file not found");
     screenshotFile = WebTestContext.Get <string>(Constants.ScreenshotFileKey);
 }
Esempio n. 5
0
 public void SetPropertyWithExistingKeyShouldOverwriteExistingValue()
 {
     WebTestContext.Set("a", "standard value");
     Assert.True(WebTestContext.Get <string>("a").Equals("standard value"), "Value should have persisted");
     WebTestContext.Set("a", "default value");
     Assert.True(WebTestContext.Get <string>("a").Equals("default value"), "Value should have been overwritten");
 }
        public void CreateLocalIOSDriver()
        {
            driverConfig = new LocalDriverConfig
            {
                PlatformName      = MobilePlatform.IOS,
                PlatformVersion   = "10.1",
                BrowserName       = MobileBrowserType.Safari,
                DeviceName        = "device name",
                ServerUrl         = serverUrl,
                NewCommandTimeout = 90001,
                ImplicitWait      = 90002,
                PageLoad          = 90003
            };
            var testSettings = new TestSettingsConfig();

            testSettings.LocalDriver = driverConfig;

            var webTestContext = new WebTestContext(mockDriverFactory.Object, testSettings);

            webTestContext.StartDriver();
            mockDriverFactory.Verify(IDriverFactory => IDriverFactory.Create(It.IsAny <Uri>(), It.IsAny <DriverOptions>(), It.IsAny <TimeSpan>(), It.IsAny <Action <IWebDriver> >()), Times.Once);
            Assert.AreEqual(driverConfig.BrowserName, receivedCapabilities.GetCapability(MobileCapabilityType.BrowserName), "BrowserName is not equal");
            Assert.AreEqual(driverConfig.PlatformVersion, receivedCapabilities.GetCapability(MobileCapabilityType.PlatformVersion), "PlatformVersion is not equal");
            Assert.AreEqual(driverConfig.PlatformName, receivedCapabilities.GetCapability(MobileCapabilityType.PlatformName), "PlatformVersion is not equal");
            Assert.AreEqual(driverConfig.DeviceName, receivedCapabilities.GetCapability(MobileCapabilityType.DeviceName), "DeviceName is not equal");
            Assert.AreEqual(ProviderType.Default, webTestContext.ProviderType);
        }
Esempio n. 7
0
 private void ProcessObject(object obj, string keyName, WebTestContext context)
 {
     if (obj is ArrayList)
     {
         ArrayList list = obj as ArrayList;
         int counter = 1;
         foreach (object o in list)
         {
             string keyNameWithIndex = keyName + "." + counter ++;
             ProcessObject(o, keyNameWithIndex, context);
         }
     }
     else if (obj is Hashtable)
     {
         Hashtable table = obj as Hashtable;
         foreach (DictionaryEntry entry in table)
         {
             string keyNameWithProperty = keyName + "." + entry.Key;
             ProcessObject(entry.Value, keyNameWithProperty, context);
         }
     }
     else
     {
         context[keyName] = obj;
     }
 }
Esempio n. 8
0
            public void BeforeScenario()
            {
                logger.Info(String.Format("Working directory: {0}", Environment.CurrentDirectory));
                WebTestContext webTestContext = new WebTestContext(driverFactory, testSettings);

                webTestContext.StartDriver();
                ScenarioContext.Current.Add(ScenarioContextTypes.Driver, webTestContext);
            }
Esempio n. 9
0
 public void AfterScenario()
 {
     if (ScenarioContext.Current.ContainsKey(ScenarioContextTypes.Driver))
     {
         WebTestContext testContext = ScenarioContext.Current.Get <WebTestContext>(ScenarioContextTypes.Driver);
         testContext.QuitDriver();
     }
 }
Esempio n. 10
0
        public void  CanStartServiceWhenAllRequiredParamsSet()
        {
            BaseDriverService.Start(parameter);
            Assert.NotNull(WebTestContext.Get <DriverService>(Constants.DriverServiceKey), "Service should have started and context set");
            var service = WebTestContext.Get <DriverService>(Constants.DriverServiceKey);

            Assert.True(service.IsRunning, "Service must be running");
            Assert.AreEqual(service.ServiceUrl, parameter.ServerUri, "Service URL should have been updated");
        }
Esempio n. 11
0
 public static void SetupTestArtifacts()
 {
     if (Convert.ToBoolean(WebTestContext.Get <string>(nameof(Constants.DevelopmentMode), false)))
     {
         return;
     }
     SetupTestLog();
     SetupScreenshotFileName();
 }
Esempio n. 12
0
        public void LaunchChromeBrowserAgain()
        {
            Assert.DoesNotThrow((() => WebTestContext.Get <RemoteWebDriver>(nameof(WebDriver))), "Driver should be set in the current context.");
            Assert.NotNull(WebTestContext.Get <RemoteWebDriver>(nameof(WebDriver)), $"Driver should not be null");
            Console.WriteLine($"Thread:{Thread.CurrentThread.ManagedThreadId}");
            var driver = WebDriver.Instance;

            driver.Navigate().GoToUrl("http://google.com");
            Wait.ForPageToLoad();
            driver.FindVisibleAndEnabled(By.CssSelector("input[name='q']")).SendKeys("Hello world from Method2");
        }
 public virtual void TestSetup()
 {
     //Start driver service
     DriverService.Start(this.TestEnvironmentParameters);
     //Merge user provided options to existing default capabilities.
     Capabilities.MergeCapabilities(RunParameterUpdater);
     // Write Runsettings to log file
     TestLogs.WriteLogSection("Original Test Run Parameters", () => TestLogs.Write(this.TestEnvironmentParameters.ToString()));
     WebDriver.Initialize(Capabilities);
     //Write device configuration to log file
     TestLogs.WriteLogSection("DUT Configuration", () => TestLogs.Write(WebDriver.Instance.Capabilities.ToString()));
     WebTestContext.Set(Constants.TestEnvironmentKey, TestEnvironmentParameters);
     TestLogs.AddSection($"Test {TestContext.CurrentContext.Test.Name} Starts");
 }
Esempio n. 14
0
 public static string ResolveContextValue(WebTestContext context, string value)
 {
     return(_FindContextKey.Replace(value, new MatchEvaluator((m) => {
         string keyName = m.Groups[1].Value;
         if (context.ContainsKey(keyName))
         {
             return context[keyName].ToString();
         }
         else
         {
             throw new ApplicationException(string.Format("Key {0} not found in Context", keyName));
         }
     })));
 }
Esempio n. 15
0
        public override void CheckCondition(object sender, ConditionalEventArgs e)
        {
            try
            {
                WebTestContext context = e.WebTest.Context;

                e.IsMet   = ReportHelper.Init(StorageAccountName, StorageAccountKey, TestName);
                e.Message = "Azure Storage " + (e.IsMet ? "" : "not") + "found";
            }
            catch
            {
                e.IsMet = false;
            }
        }
        /// <summary>
        /// Find all javascript:__doPostback(...) type declarations which indicates
        /// all controls that support postback. It finds all such controls that support
        /// postback and then stores the full client ID of the control in Context
        /// using the last part of the ID as key in Context. For example:
        /// $POSTBACK.1.AddNewWidget = WidgetUpdatePanel001$ctl_002$AddNewWidget
        /// This way you can find a paricular controls full client ID when you know only the
        /// server ID of the control.
        /// </summary>
        /// <param name="bodyHtml">Body HTML</param>
        /// <param name="context">WebTest Context</param>
        public static void ExtractPostBackNames(string bodyHtml, WebTestContext context)
        {
            RuleHelper.NotAlreadyDone(context, "$POSTBACK.EXTRACTED", () =>
                {
                    var matches = _FindPostbackNames.Matches(bodyHtml);
                    foreach (Match match in matches)
                    {
                        string fullID = match.Groups[1].Value;
                        string lastPartOfID = fullID.Substring(fullID.LastIndexOf('$') + 1);
                        string contextKeyName = "$POSTBACK." + lastPartOfID;

                        RuleHelper.PlaceUniqueItem(context, contextKeyName, fullID);
                    }
                });
        }
        public static string Replace(string source, WebTestContext context)
        {
            var processed = new StringBuilder(source);
            var tokens    = Regex.Matches(source, @"{{(\w+)}}");

            if (tokens.Count > 0)
            {
                foreach (Match token in tokens)
                {
                    processed = processed.Replace(token.Value,
                                                  context[token.Groups[1].Value].ToString());
                }
            }
            return(processed.ToString());
        }
Esempio n. 18
0
        public override void Extract(object sender, ExtractionEventArgs e)
        {
            JsonExtractionRule msgIdExtractionRule =
                new JsonExtractionRule()
            {
                ContextParameterName = this.ContextParameterName, Name = ParamToExtract
            };

            msgIdExtractionRule.Extract(sender, e);

            WebTestContext context = e.WebTest.Context;

            try
            {
                if (context.ContainsKey(Constants.Context_MessageId) &&
                    context.ContainsKey(Constants.Context_UserActivity))
                {
                    string   jsonInput = context[Constants.Context_UserActivity].ToString();
                    Activity activity  = JsonConvert.DeserializeObject <Activity>(jsonInput);
                    activity.Conversation =
                        new ConversationAccount()
                    {
                        Id = context[Constants.Context_ConvId].ToString()
                    };

                    activity.Id = context[Constants.Context_MessageId].ToString();

                    context[Constants.Context_UserActivity] = JsonConvert.SerializeObject(activity);
                    int waterMark = int.Parse(context[Constants.Context_MessageId].ToString().Split('|')[1]);
                    if (waterMark > 1)
                    {
                        waterMark--;
                    }

                    context[Constants.Context_Watermark] = $"/{waterMark}";
                    e.Success = true;
                }
                else
                {
                    e.Success = false;
                    e.Message = "Message Id or User Activity not found";
                }
            }
            catch
            {
                e.Success = false;
            }
        }
Esempio n. 19
0
        public static bool NotAlreadyDone(WebTestContext context, string stepKey, Action callback)
        {
            int    stepNo  = (int)context[ASPNETWebTestPlugin.STEP_NO_KEY];
            string keyName = stepKey + "." + stepNo;

            if (context.ContainsKey(keyName))
            {
                return(false);
            }
            else
            {
                callback();
                context[keyName] = true;
                return(true);
            }
        }
Esempio n. 20
0
        private static void SetupScreenshotFileName()
        {
            string testScreenshotFullPath = Path.Combine(screenshotFolder, TestContext.CurrentContext.Test.Name + ".jpeg");

            if (File.Exists(testScreenshotFullPath))
            {
                try {
                    File.Delete(testScreenshotFullPath);
                } catch (UnauthorizedAccessException e) {
                    Console.WriteLine("Cannot cleanup test screenshot file", e);
                } catch (Exception ex) {
                    Console.WriteLine("Cannot cleanup test screenshot file", ex);
                }
            }
            WebTestContext.Set(Constants.ScreenshotFileKey, Path.Combine(screenshotFolder, TestContext.CurrentContext.Test.Name + ".jpeg"));
        }
Esempio n. 21
0
        private static void SetupTestLog()
        {
            string testFileNameFullPath = Path.Combine(testLogFolder, TestContext.CurrentContext.Test.Name + ".log");

            if (File.Exists(testFileNameFullPath))
            {
                try {
                    File.Delete(testFileNameFullPath);
                } catch (Exception e) {
                    Console.WriteLine($"Cannot cleanup the log file: {e}");
                }
            }

            File.Create(testFileNameFullPath).Close();

            WebTestContext.Set(Constants.TestLogFileKey, testFileNameFullPath);
        }
Esempio n. 22
0
        /// <summary>
        /// Start browser specific driver service
        /// </summary>
        /// <param name="parameters"><see cref="TestEnvironmentParameters"/></param>
        private static void StartBrowserService(TestEnvironmentParameters parameters)
        {
            OpenQA.Selenium.DriverService service;

            switch (parameters.RS_BrowserName.ToUpper())
            {
            case "CHROME":
                service          = ChromeDriverService.CreateDefaultService(parameters.RS_DriverServerExePath);
                service.HostName = parameters.RS_ServerHost;
                service.Port     = Convert.ToInt32(parameters.RS_ServerPort);

                Get(() => service.Start(), "Chrome");
                break;

            case "IE":
                service          = InternetExplorerDriverService.CreateDefaultService(parameters.RS_DriverServerExePath);
                service.HostName = parameters.RS_ServerHost;
                service.Port     = Convert.ToInt32(parameters.RS_ServerPort);
                Get(() => service.Start(), "ie");
                break;

            case "EDGE":
                service          = EdgeDriverService.CreateDefaultService(parameters.RS_DriverServerExePath);
                service.HostName = parameters.RS_ServerHost;
                service.Port     = Convert.ToInt32(parameters.RS_ServerPort);
                Get(() => service.Start(), "Edge");
                break;

            case "SAFARI":
                service          = SafariDriverService.CreateDefaultService(parameters.RS_DriverServerExePath);
                service.HostName = parameters.RS_ServerHost;
                service.Port     = Convert.ToInt32(parameters.RS_ServerPort);
                Get(() => service.Start(), "Safari");
                break;

            default:
                throw new DriverServiceException($"Driver for {parameters.RS_BrowserName} not supported.");
            }

            WebTestContext.Set(Constants.DriverServiceKey, service);
            parameters.ServerUri = service.ServiceUrl;
        }
Esempio n. 23
0
        public DocumentManagement_C()
        {
            if (_DocumentManagement == null)
            {
                _DocumentManagement = new DocumentManagement(this);
            }


            this.Context.Add("LoginMain", AssemblyLoad.LoginMain);
            this.Context.Add("AccountingURL", AssemblyLoad.AccountingURL);
            this.Context.Add("TwfcndURL", AssemblyLoad.TwfcndURL);
            this.PreAuthenticate = true;
            this.Proxy           = "default";
            this.StopOnError     = true;
            _textContext         = this.Context;

            this.PreWebTest  += TwinfieldWebLoadTestPlugin.PreWebTestEvent;
            this.PreRequest  += objPlugin.Test_PreRequest;
            this.PostRequest += objPlugin.Test_PostRequest;
        }
Esempio n. 24
0
        public UserAccessSettings_E()
        {
            if (_UserAccessSettings == null)
            {
                _UserAccessSettings = new UserAccessSettings(this);
            }


            this.Context.Add("LoginMain", AssemblyLoad.LoginMain);
            this.Context.Add("AccountingURL", AssemblyLoad.AccountingURL);
            this.Context.Add("TwfcndURL", AssemblyLoad.TwfcndURL);
            this.PreAuthenticate = true;
            this.Proxy           = "default";
            this.StopOnError     = true;
            _textContext         = this.Context;

            this.PreWebTest  += TwinfieldWebLoadTestPlugin.PreWebTestEvent;
            this.PreRequest  += objPlugin.Test_PreRequest;
            this.PostRequest += objPlugin.Test_PostRequest;
        }
        public CreateTransaction_D()
        {
            if (_CreateTransaction == null)
            {
                _CreateTransaction = new CreateTransaction(this);
            }


            this.Context.Add("LoginMain", AssemblyLoad.LoginMain);
            this.Context.Add("AccountingURL", AssemblyLoad.AccountingURL);
            this.Context.Add("TwfcndURL", AssemblyLoad.TwfcndURL);
            this.PreAuthenticate = true;
            this.Proxy           = "default";
            this.StopOnError     = true;
            _textContext         = this.Context;

            this.PreWebTest  += TwinfieldWebLoadTestPlugin.PreWebTestEvent;
            this.PreRequest  += objPlugin.Test_PreRequest;
            this.PostRequest += objPlugin.Test_PostRequest;
        }
Esempio n. 26
0
        public void StartLocalChromeDriver()
        {
            string serverUrl = "http://localhost:4444/wd/hub";

            driverConfig = new LocalDriverConfig
            {
                BrowserName       = MobileBrowserType.Chrome,
                ServerUrl         = serverUrl,
                NewCommandTimeout = 90001,
                ImplicitWait      = 90002,
                PageLoad          = 90003
            };
            var testSettings = new TestSettingsConfig();

            testSettings.LocalDriver = driverConfig;

            webTestContext = new WebTestContext(new DriverFactory(), testSettings);
            webTestContext.StartDriver();
            Assert.IsInstanceOf <RemoteWebDriver>(webTestContext.Driver());
        }
Esempio n. 27
0
        public static void ExtractUpdatePanelNamesFromHtml(string body, WebTestContext context)
        {
            RuleHelper.NotAlreadyDone(context, UPDATEPANEL_EXTRACTED_KEY, () =>
            {
                // Do not extract update panel names twice
                int pos = body.IndexOf(UPDATE_PANEL_DECLARATION);
                if (pos > 0)
                {
                    // found declaration of all update panels on the page
                    pos       += UPDATE_PANEL_DECLARATION.Length;
                    int endPos = body.IndexOf(']', pos);
                    string updatePanelNamesDelimited = body.Substring(pos, endPos - pos);
                    string[] updatePanelNames        = updatePanelNamesDelimited.Split(',');
                    int updatePanelCounter           = 1;
                    foreach (string updatePanelName in updatePanelNames)
                    {
                        // Create a unique key in the context using the UpdatePanel's Last part of the ID which is usually the
                        // ID specified in aspx page
                        string updatePanelFullId     = updatePanelName.TrimStart('\'').TrimEnd('\'').TrimStart('t');
                        string updatePanelIdLastPart = updatePanelFullId.Substring(updatePanelFullId.LastIndexOf('$') + 1);
                        string contextKeyName        = UPDATE_PANEL_PREFIX + updatePanelIdLastPart;
                        string keyName = RuleHelper.PlaceUniqueItem(context, contextKeyName, updatePanelFullId);

                        // Store all update panels as $UPDATEPANEL.1, $UPDATEPANEL.2, ...
                        context[UPDATE_PANEL_PREFIX + updatePanelCounter] = updatePanelFullId;

                        // Find the position of the UpdatePanel
                        string updatePanelDivId = updatePanelFullId.Replace('$', '_');
                        // Look for a div with id having the updatepanel ID, e.g. <div id="UserTabPage_TabUpdatePanel">
                        string lookingFor       = "<div id=\"" + updatePanelDivId + "\"";
                        int updatePanelDivIdPos = body.IndexOf(lookingFor);
                        context[UPDATE_PANEL_PREFIX + updatePanelCounter + UPDATE_PANEL_POS_KEY] = updatePanelDivIdPos;
                        context[keyName + UPDATE_PANEL_POS_KEY] = updatePanelDivIdPos;

                        updatePanelCounter++;
                    }

                    context[UPDATE_PANEL_COUNT_KEY] = updatePanelCounter;
                }
            });
        }
        public static void ExtractUpdatePanelNamesFromHtml(string body, WebTestContext context)
        {
            RuleHelper.NotAlreadyDone(context, UPDATEPANEL_EXTRACTED_KEY, () =>
                {
                    // Do not extract update panel names twice
                    int pos = body.IndexOf(UPDATE_PANEL_DECLARATION);
                    if (pos > 0)
                    {
                        // found declaration of all update panels on the page
                        pos += UPDATE_PANEL_DECLARATION.Length;
                        int endPos = body.IndexOf(']', pos);
                        string updatePanelNamesDelimited = body.Substring(pos, endPos - pos);
                        string[] updatePanelNames = updatePanelNamesDelimited.Split(',');
                        int updatePanelCounter = 1;
                        foreach (string updatePanelName in updatePanelNames)
                        {
                            // Create a unique key in the context using the UpdatePanel's Last part of the ID which is usually the
                            // ID specified in aspx page
                            string updatePanelFullId = updatePanelName.TrimStart('\'').TrimEnd('\'').TrimStart('t');
                            string updatePanelIdLastPart = updatePanelFullId.Substring(updatePanelFullId.LastIndexOf('$') + 1);
                            string contextKeyName = UPDATE_PANEL_PREFIX + updatePanelIdLastPart;
                            string keyName = RuleHelper.PlaceUniqueItem(context, contextKeyName, updatePanelFullId);

                            // Store all update panels as $UPDATEPANEL.1, $UPDATEPANEL.2, ...
                            context[UPDATE_PANEL_PREFIX + updatePanelCounter] = updatePanelFullId;

                            // Find the position of the UpdatePanel
                            string updatePanelDivId = updatePanelFullId.Replace('$', '_');
                            // Look for a div with id having the updatepanel ID, e.g. <div id="UserTabPage_TabUpdatePanel">
                            string lookingFor = "<div id=\"" + updatePanelDivId + "\"";
                            int updatePanelDivIdPos = body.IndexOf(lookingFor);
                            context[UPDATE_PANEL_PREFIX + updatePanelCounter + UPDATE_PANEL_POS_KEY] = updatePanelDivIdPos;
                            context[keyName + UPDATE_PANEL_POS_KEY] = updatePanelDivIdPos;

                            updatePanelCounter++;
                        }

                        context[UPDATE_PANEL_COUNT_KEY] = updatePanelCounter;
                    }
                });
        }
        public void CreateLocalRemoteWebDriver()
        {
            driverConfig = new LocalDriverConfig
            {
                PlatformName      = "",
                BrowserName       = "Chrome",
                ServerUrl         = serverUrl,
                NewCommandTimeout = 90001,
                ImplicitWait      = 90002,
                PageLoad          = 90003
            };
            var testSettings = new TestSettingsConfig();

            testSettings.LocalDriver = driverConfig;

            var webTestContext = new WebTestContext(mockDriverFactory.Object, testSettings);

            webTestContext.StartDriver();
            mockDriverFactory.Verify(IDriverFactory => IDriverFactory.Create(It.IsAny <Uri>(), It.IsAny <DriverOptions>(), It.IsAny <TimeSpan>(), It.IsAny <Action <IWebDriver> >()), Times.Once);
            Assert.AreEqual(ProviderType.Default, webTestContext.ProviderType);
        }
Esempio n. 30
0
        public override void Validate(object sender, ValidationEventArgs e)
        {
            if (e.Response.StatusCode == HttpStatusCode.OK)
            {
                WebTestContext context = e.WebTest.Context;

                context[Constants.Context_MessagePostedToBot] = true;
                context[Constants.Context_TestStatus]         = true;
                context[Constants.Context_ActualResult]       = "Sent";

                if (context.ContainsKey(Constants.Context_MessageId) && context.ContainsKey(Constants.Context_UserActivity))
                {
                    string   jsonInput = context[Constants.Context_UserActivity].ToString();
                    Activity activity  = JsonConvert.DeserializeObject <Activity>(jsonInput);
                    activity.Timestamp = DateTime.UtcNow.AddSeconds(-2);
                    context[Constants.Context_UserActivity] = JsonConvert.SerializeObject(activity, new JsonSerializerSettings()
                    {
                        NullValueHandling = NullValueHandling.Ignore
                    });
                }
            }
        }
Esempio n. 31
0
        public void StartLocalAndroidDriver()
        {
            string serverUrl = "http://localhost:4723/wd/hub";

            driverConfig = new LocalDriverConfig
            {
                PlatformName      = MobilePlatform.Android,
                BrowserName       = MobileBrowserType.Chrome,
                DeviceName        = "Android Emulator",
                ServerUrl         = serverUrl,
                NewCommandTimeout = 90001,
                ImplicitWait      = 90002,
                PageLoad          = 90003
            };
            var testSettings = new TestSettingsConfig();

            testSettings.LocalDriver = driverConfig;

            webTestContext = new WebTestContext(new DriverFactory(), testSettings);
            webTestContext.StartDriver();
            Assert.IsInstanceOf <AndroidDriver <IWebElement> >(webTestContext.Driver());
        }
Esempio n. 32
0
        public static string PlaceUniqueItem(WebTestContext context, string keyPrefix, object value)
        {
            int i = 1;

            while (context.ContainsKey(keyPrefix + "." + i))
            {
                if (((IComparable)context[keyPrefix + "." + i]).Equals(value))
                {
                    break; // We already have this exact control in Context.
                }
                else
                {
                    i++; // Another instance of the same Control. Try another number in Key.
                }
            }

            string keyName = keyPrefix + "." + i;

            context[keyName] = value;

            return(keyName);
        }
Esempio n. 33
0
 public Navigation(WebTestContext context) : base(context)
 {
 }
Esempio n. 34
0
 public Catalog(WebTestContext context) : base(context)
 {
 }
        private void ExtractUpdatePanelNamesFromAsyncPostback(string body, WebTestContext context)
        {
            RuleHelper.NotAlreadyDone(context, "$UPDATEPANEL.EXTRACTED", () =>
                {
                    int newUpdatePanelsAdded = 0;
                    foreach (Match match in _FindUpdatePanelRegex.Matches(body))
                    {
                        string updatePanelDivID = match.Groups["name"].Value;
                        string updatePanelFullId = updatePanelDivID.Replace('_', '$');
                        string updatePanelIdLastPart = updatePanelFullId.Substring(updatePanelFullId.LastIndexOf('$') + 1);

                        string contextKeyName = UPDATE_PANEL_PREFIX + updatePanelIdLastPart;
                        string keyName = RuleHelper.PlaceUniqueItem(context, contextKeyName, updatePanelFullId);

                        int countOfKeys = context.Count;
                        RuleHelper.PlaceUniqueItem(context, UPDATE_PANEL_KEY, updatePanelFullId);
                        if (context.Count > countOfKeys)
                            newUpdatePanelsAdded++;
                    }

                    context[UPDATE_PANEL_COUNT_KEY] = ((int)context[UPDATE_PANEL_COUNT_KEY]) + newUpdatePanelsAdded;
                });
        }
Esempio n. 36
0
		public StepsBase(WebTestContext context)
		{
			Context = context;
		}	
Esempio n. 37
0
 private string BuildJSON(WebTestContext context, string json)
 {
     // Replace all context params
     return _FindContextParamJSON.Replace(json, new MatchEvaluator((match) => context[match.Value] as string));
 }