/// <summary>
 /// The log unsafe driver settings.
 /// </summary>
 /// <param name="driverOptions">
 /// The driver options.
 /// </param>
 private void LogUnsafeDriverSettings(InternetExplorerOptions driverOptions)
 {
     if (driverOptions.IntroduceInstabilityByIgnoringProtectedModeSettings)
     {
         StfLogger.LogWarning("Driver is configured to ignore protected mode settings. This could cause instabillity!");
     }
 }
        /// <summary>
        /// The textbox set text by.
        /// </summary>
        /// <param name="by">
        /// The by.
        /// </param>
        /// <param name="textToEnter">
        /// The text to enter.
        /// </param>
        /// <param name="handlePopup">
        /// Some text boxes have a search popup ... This switch is default false
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        private bool TextboxSetTextBy(By by, string textToEnter, bool handlePopup = false)
        {
            StfLogger.LogDebug($"Textbox : Setting text [{textToEnter}] - by=[{by}]");
            WaitForComplete(2);

            var element = FindElement(by);

            if (element == null)
            {
                StfLogger.LogError($"Can't find textbox - by=[{by}]");

                return(false);
            }

            try
            {
                element.Clear();
                element.SendKeys(textToEnter);

                if (handlePopup)
                {
                    // handle the funky suggestion popup, by selecting the first in the list
                    var popupFirstElement = FindElement(By.XPath("//li[@class='ui-menu-item'][1]"));

                    if (popupFirstElement == null)
                    {
                        StfLogger.LogWarning("TextboxSetTextBy: Was instructed to handle popup - but no element was found");
                        return(false);
                    }

                    popupFirstElement.Click();
                }
                else
                {
                    element.SendKeys(Keys.Tab);
                }
            }
            catch (Exception ex)
            {
                StfLogger.LogError($"Can't send text to textbox - ex=[{ex}]");

                return(false);
            }

            return(true);
        }
Exemple #3
0
        /// <summary>
        /// The kill process.
        /// </summary>
        /// <param name="processName">
        /// The process name.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        private bool KillProcesses(string processName)
        {
            StfLogger.LogDebug("Starting to kill all processes with name [{0}]", processName);

            var seleniumDriverProcesses = Process.GetProcesses().Where(pr => pr.ProcessName == processName);
            var retVal = true;

            foreach (var process in seleniumDriverProcesses)
            {
                try
                {
                    StfLogger.LogDebug("Killing process with ID [{0}]", process.Id);
                    process.Kill();
                }
                catch (Exception ex)
                {
                    StfLogger.LogWarning("Challenges killing one process [{0}]", ex.Message);
                    retVal = false;
                }
            }

            // Process does not leave the process list immediately, stays in there as hasexited = true
            Thread.Sleep(Configuration.WaitTimeForProcessExit);

            // note if we did indeed kill all the processes...
            seleniumDriverProcesses = Process.GetProcesses().Where(pr => pr.ProcessName == processName);
            var allProcessKilled = !seleniumDriverProcesses.Any();

            retVal = retVal && allProcessKilled;

            if (!retVal)
            {
                StfLogger.LogError("Challenges killing processes{0}", !allProcessKilled ? " - Still some processes left to kill" : string.Empty);
            }

            return(retVal);
        }