Esempio n. 1
0
        private void OnElementClicked(object sender, WebElementEventArgs e)
        {
            this.Pause(2);
            var navigated = new Uri(Navigator.driver.Url);

            this.SetCurrentPage(navigated);
        }
 private void WebDriver_ElementClicking(object sender, WebElementEventArgs e)
 {
     using (StreamWriter sw = new StreamWriter(Report, true))
     {
         sw.WriteLine($"<center><h4>Click | Element: {e.Element.TagName} {e.Element.Text}</h4></center>");
     }
 }
 protected override void OnElementClicking(WebElementEventArgs e)
 {
     Console.WriteLine("Clicking on element Name: " + e.Element.GetAttribute("name")
                       + " Id: " + e.Element.GetAttribute("id")
                       + " Enabled: " + e.Element.Enabled
                       + " Displayed: " + e.Element.Displayed);
 }
        public string GetDescription(WebElementEventArgs e)
        {
            try
            {
                if (!String.IsNullOrEmpty(e.Element.GetAttribute("id")))
                {
                    return(e.Element.TagName + " " + e.Element.GetAttribute("type") + " [Id=" + e.Element.GetAttribute("id") + ']');
                }

                if (!String.IsNullOrEmpty(e.Element.GetAttribute("class")))
                {
                    return(e.Element.TagName + " " + e.Element.GetAttribute("type") + " [Class=" + e.Element.GetAttribute("class") + ']');
                }

                if (!String.IsNullOrEmpty(e.Element.GetAttribute("name")))
                {
                    return(e.Element.TagName + " " + e.Element.GetAttribute("type") + " [Name=" + e.Element.GetAttribute("name") + ']');
                }

                if (!String.IsNullOrEmpty(e.Element.GetAttribute("innertext")))
                {
                    return(e.Element.TagName + " " + e.Element.GetAttribute("type") + " [InnerText=" + e.Element.GetAttribute("innertext") + ']');
                }
            }
            catch (Exception)
            {
                // ignored
            }

            return("");
        }
Esempio n. 5
0
 private string GetLogMessage(string command, WebElementEventArgs e = null, string param = "")
 {
     if (param != "")
     {
         param = "'" + param + "'";
     }
     return(string.Format(errorMessage, TestBase.GetCurrentClassAndMethodName(), command, e.Element.GetHtml(), param));
 }
        private void EventDriver_ElementValueChanging(object sender, WebElementEventArgs e)
        {
            Trace.TraceEvent(TraceEventType.Verbose,
                             Constants.Tracing.BrowserElementValueChangingEventId,
                             string.Format("ElementValueChanging - [{0},{1}] - <{2}>{3}</{2}>", e.Element.Location.X, e.Element.Location.Y, e.Element.TagName, e.Element.Text));

            OnElementValueChanging(e);
        }
Esempio n. 7
0
        /// <summary>
        /// Metoda určena k exekuci akcí po události <see cref="EventFiringWebDriver.ElementClicking"/>
        /// Element se pokusí zvýraznit
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void EventFiringWebDriver_createScreenShot_click(object sender, WebElementEventArgs args)
        {
            ((IJavaScriptExecutor)args.Driver).ExecuteScript("arguments[0].style.outline='4px solid red'", args.Element);
            string screenShotFile = GetLogDir() + "/screenshot_" + (++PageOrder).ToString().PadLeft(2, '0') + ".png";

            Utils.SaveScreenshotAsFile(GetWebDriver(), screenShotFile);
            Logger.Debug("Screenshot uložen do souboru '{0}'", screenShotFile);
        }
Esempio n. 8
0
    protected override void OnElementClicking(WebElementEventArgs e)
    {
        _driver.Sync();
        string type = getTypeofElement(e.Element.TagName);

        base.OnElementClicking(e);
        Reporter.Logtofile("Clicked on element:" + e.Element.Text + " of type:" + type, Status.Info);
        _driver.Sync();
    }
Esempio n. 9
0
 static void MyElementClickedHandler(object sender, WebElementEventArgs e)
 {
     try
     {
         Console.WriteLine("Clicked on " + e.Element.Text);
     }
     catch (Exception)
     {
     }
 }
Esempio n. 10
0
 /// <summary>
 /// Event for webdriver that has clicked an element
 /// </summary>
 /// <param name="sender">Sender object</param>
 /// <param name="e">Event object</param>
 private void WebDriver_ElementClicked(object sender, WebElementEventArgs e)
 {
     try
     {
         this.LogVerbose("Element clicked: {0} Text:{1} Location: X:{2} Y:{3}", e.Element, e.Element.Text, e.Element.Location.X, e.Element.Location.Y);
     }
     catch
     {
         this.LogVerbose("Element clicked");
     }
 }
        private void OnElementClicking(object sender, WebElementEventArgs webElementEventArgs)
        {
            SeleniumLog log = SeleniumLog.Instance();

            if (log.Config.OnClick_LogBeforeEvent)
            {
                log.Indent();
                log.Debug("[Selenium Event]  Clicking Element: " + _locator, take_screenshot: log.Config.OnClick_TakeScreenshotBeforeEvent);
                log.Unindent();
            }
        }
Esempio n. 12
0
 /// <summary>
 /// Event for webdriver that has clicked an element
 /// </summary>
 /// <param name="sender">Sender object</param>
 /// <param name="e">Event object</param>
 private void WebDriver_ElementClicked(object sender, WebElementEventArgs e)
 {
     try
     {
         this.LogVerbose($"Element clicked: {e.Element} Text:{e.Element.Text} Location: X:{e.Element.Location.X} Y:{e.Element.Location.Y}");
     }
     catch
     {
         this.LogVerbose("Element clicked");
     }
 }
Esempio n. 13
0
 /// <summary>
 /// Waits 5 seconds when an element is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 static void driver_ElementClicked(object sender, WebElementEventArgs e)
 {
     if (((OpenQA.Selenium.Support.Events.EventFiringWebDriver)(driver)).WrappedDriver.ToString() == "OpenQA.Selenium.Safari.SafariDriver")
     {
         Thread.Sleep(TimeSpan.FromSeconds(5));
     }
     else
     {
         Thread.Sleep(TimeSpan.FromSeconds(0.75));
     }
 }
Esempio n. 14
0
 private void driver_ElementValueChanging(object sender, WebElementEventArgs e)
 {
     try
     {
         driver.WaitForJQuery();
         e.Element.Highlight(30, "red");
     }
     catch (Exception)
     {
     }
 }
        private void OnElementClicked(object sender, WebElementEventArgs webElementEventArgs)
        {
            //Console.WriteLine("ElementClicked: " + webElementEventArgs.Element);
            SeleniumLog log = SeleniumLog.Instance();

            if (log.Config.OnClick_LogAfterEvent)
            {
                log.Indent();
                log.Debug("[Selenium Event]  Click Success!", take_screenshot: log.Config.OnClick_TakeScreenshotAfterEvent);
                log.Unindent();
            }
        }
Esempio n. 16
0
        private void EventDriver_ElementClicking(object sender, WebElementEventArgs e)
        {
            Trace.TraceEvent(TraceEventType.Verbose,
                             Constants.Tracing.BrowserElementClickingEventId,
                             string.Format("ElementClicking - [{0},{1}] - <{2}>{3}</{2}>", e.Element.Location.X, e.Element.Location.Y, e.Element.TagName, e.Element.Text));

            //Logs.Log("Verbose 4", TraceEventType.Verbose.ToString(), Constants.Tracing.BrowserElementClickingEventId.ToString(),
            //        string.Format("ElementClicking - [{0},{1}] - <{2}>{3}</{2}>", e.Element.Location.X, e.Element.Location.Y,
            //        e.Element.TagName, e.Element.Text));

            OnElementClicking(e);
        }
 private void driver_ElementValueChanged(object sender, WebElementEventArgs e)
 {
     try
     {
         if (Config.Settings.reportSettings.commandLogging)
         {
             TestBase.LogEvent(GetLogMessage("Typing", e, e.Element.GetAttribute("value")));
         }
     }
     catch (Exception)
     {
     }
 }
Esempio n. 18
0
        private string GetLogMessage(string command, WebElementEventArgs e = null, string param = "")
        {
            if (param != "")
            {
                param = "'" + param + "'";
            }

            if (TestBase.testData.lastElement.name != "Element")
            {
                return(string.Format(errorMessage, TestBase.GetCurrentClassAndMethodName(), command, TestBase.testData.lastElement.name, TestBase.testData.lastElement.by, param));
            }

            return(string.Format(errorMessage, TestBase.GetCurrentClassAndMethodName(), command, "Element", TestBase.testData.lastElement.by, param));
        }
 private static void FiringDriver_Cliked(object sender, WebElementEventArgs e)
 {
     try
     {
         var elem = e.Element.GetAttribute("Id");
         _reportingTasks.Log(Status.Pass, "User click " + elem);
     }
     catch (StaleElementReferenceException ex)
     {
     }
     catch (NoSuchWindowException ew)
     {
     }
 }
        private void driver_ElementClicking(object sender, WebElementEventArgs e)
        {
            Common.Delay(Config.Settings.runTimeSettings.CommandDelayMs);
            if (Config.Settings.reportSettings.commandLogging)
            {
                TestBase.LogEvent(GetLogMessage("Click", e));
            }

            if (e.Element == null)
            {
                throw new NoSuchElementException(string.Format("Element '{0}' not present, cannot click on it",
                                                               e.Element));
            }
        }
Esempio n. 21
0
 private void driver_ElementValueChanged(object sender, WebElementEventArgs e)
 {
     try
     {
         if (Config.settings.reportSettings.commandLogging)
         {
             Log.Message(GetLogMessage("Typing", e, e.Element.GetAttribute("value")));
         }
         Common.Delay(Config.settings.runTimeSettings.CommandDelayMs);
     }
     catch (Exception)
     {
     }
 }
        void firingDriver_ElementClicked(object sender, WebElementEventArgs e)
        {
            Util.Wait(1);
            int len1 = GetBrowser().PageSource.Length;

            double        time = Double.Parse(ConfigurationManager.AppSettings.Get("timeToLoad"));
            WebDriverWait wait = new WebDriverWait(GetBrowser(), TimeSpan.FromSeconds(time));

            wait.Until((x) =>
            {
                return(GetBrowser().PageSource.Length != lenSourceBeforeClick);
            });
            Util.Wait(1);
        }
Esempio n. 23
0
 public void OnElementClicked(object sender, WebElementEventArgs e)
 {
     // this actually becomes an issue if you are redirected to a different page afte clicking a button or a link
     // and that button or link is no longer present on the landing page
     try
     {
         string message = $"Clicked on element with tag name: [{e.Element?.TagName ?? ""}] and text : [{e.Element.Text}]";
         WriteMethod(Status.Info, message);
     }
     catch (StaleElementReferenceException)
     {
         WriteMethod(Status.Info, $"Clicked on element");
     }
 }
 /// <summary>
 /// To the string element.
 /// </summary>
 /// <param name="e">The <see cref="WebElementEventArgs"/> instance containing the event data.</param>
 /// <returns>Formated issue.</returns>
 private static string ToStringElement(WebElementEventArgs e)
 {
     return(string.Format(
                CultureInfo.CurrentCulture,
                "{0}{{{1}{2}{3}{4}{5}{6}{7}{8}}}",
                e.Element.TagName,
                AppendAttribute(e, "id"),
                AppendAttribute(e, "name"),
                AppendAttribute(e, "value"),
                AppendAttribute(e, "class"),
                AppendAttribute(e, "type"),
                AppendAttribute(e, "role"),
                AppendAttribute(e, "text"),
                AppendAttribute(e, "href")));
 }
        /// <summary>
        /// Is fired when you click on something
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">Object representing the element</param>
        private static void Edr_ElementClicking(object sender, WebElementEventArgs e)
        {
            string elementText = string.Empty;

            if (!string.IsNullOrEmpty(e.Element.GetText()))
            {
                elementText = e.Element.GetText();
            }
            else if (!string.IsNullOrEmpty(e.Element.GetAttribute("value")))
            {
                elementText = e.Element.GetAttribute("value");
            }

            Log.WriteLine($"// Clicked on element: '{elementText}' ({e.Element.GetAttribute("outerHTML")})");
        }
Esempio n. 26
0
 private void firingDriver_ElementClicked(object sender, WebElementEventArgs e)
 {
     try
     {
         log.Info(((IJavaScriptExecutor)driver).ExecuteScript("return document.readyState"));
         wait = new WebDriverWait(new SystemClock(), e.Driver, TimeSpan.FromSeconds(3), TimeSpan.FromMilliseconds(100));
         //wait.Until(ExpectedConditions.ElementToBeSelected(e.Element));
         wait.Until(
             driver1 => ((IJavaScriptExecutor)driver).ExecuteScript("return document.readyState").Equals("complete"));
         log.Info(((IJavaScriptExecutor)driver).ExecuteScript("return document.readyState"));
         log.Info("Clicked");
     }
     catch (Exception exception)
     {
     }
 }
        private void Driver_ElementClicked(object sender, WebElementEventArgs e)
        {
            Screenshot = ((ITakesScreenshot)Driver).GetScreenshot();

            EvidenceFileName = Path.Combine(TestResultsDirectory, "evidence" + DateTime.Now.ToString("ddMMyyyyThhmmss") + ".png");

            Screenshot.SaveAsFile(EvidenceFileName, ScreenshotImageFormat.Png);

            TestInfo = "<h5>" + Loger + "</h5><br/>ElementClicked: " + GetDescription(e) + "<br/><a target='_blank' onclick=OpenImage('data:image/png;base64," + ConvertImageToBase64(EvidenceFileName) + "')><img src='data:image/png;base64," + ConvertImageToBase64(EvidenceFileName) + "' alt='Forest'></a>";

            Test.Info(TestInfo);

            File.Delete(EvidenceFileName);

            Loger = String.Empty;
        }
Esempio n. 28
0
        private void driver_ElementClicking(object sender, WebElementEventArgs e)
        {
            if (Config.settings.reportSettings.commandLogging)
            {
                Log.Message(GetLogMessage("Click", e));
            }

            if (e.Element == null)
            {
                throw new NoSuchElementException(string.Format("Element '{0}' not present, cannot click on it",
                                                               e.Element));
            }

            driver.WaitForJQuery();
            e.Element.Highlight(30, "red");
        }
        private void OnElementValueChanged(object sender, WebElementEventArgs webElementEventArgs)
        {
            SeleniumLog log = SeleniumLog.Instance();

            if (log.Config.OnChangeValue_LogAfterEvent)
            {
                log.SaveIndent("OnElementValueChanged");
                log.Indent();
                log.Debug("[Selenium Event]  Successfully changed value [" + webElementEventArgs.Element.GetAttribute("value") + "]", take_screenshot: log.Config.OnChangeValue_TakeScreenshotAfterEvent);
                log.Unindent();

                if (!string.IsNullOrEmpty(_keyInput))
                {
                    //log.WriteLine("Input was: " + _keyInput);
                }
                log.RestoreIndent("OnElementValueChanged");
            }
        }
 /// <summary>
 /// Is fired when value of element is changed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e">Object representing the element</param>
 private static void Edr_ElementValueChanged(object sender, WebElementEventArgs e)
 {
     try
     {
         string text = e.Element.GetText();
         if (string.IsNullOrEmpty(text))
         {
             Log.WriteLineIfVerbose($"// Cleared elements value or no text put in: {e.Element.GetAttribute("outerHTML")}");
         }
         else
         {
             Log.WriteLineIfVerbose($"// Changed value: '{text}' of element '{e.Element.GetAttribute("outerHTML")}'");
         }
     }
     catch (Exception ex) when(ex is StaleElementReferenceException || ex is NoSuchElementException)
     {
         Log.WriteLineIfVerbose($"// Element is no longer present in DOM and can't be logged ({ex.Message})");
     }
 }