Пример #1
0
 private void Close_Browser_Button_Click(object sender, EventArgs e)
 {
     AU_Process_Button.Enabled = true;
     try
     {
         driver.Quit();
     }
     catch (Exception)
     {
         Log_Text_Box.AppendText(DateTime.Now.ToString("[M/d/yyyy @ h:mm:stt] ") + "There are no open browsers." + "\r\n");
     }
 }
Пример #2
0
      ////////////////////////////////////////////////////////////////
      //------------------------------------------------------------//
      ////////////////////////////////////////////////////////////////

      #region Initialize
      public KMSWindow()
      {
          InitializeComponent();
          CheckConfigAviableAndLoadOrCreate();

          try {
              Main_Output_Audio_Deveic = new CoreAudioController().DefaultPlaybackDevice;
          }
          catch (IOException es)
          {
              Log_Text_Box.AppendText(es + Environment.NewLine);
          }

          try
          {
              Main_Output_Audio_Deveic = new CoreAudioController().DefaultPlaybackDevice;
          }
          catch (IOException es)
          {
              Log_Text_Box.AppendText(es + Environment.NewLine);
          }
      }
Пример #3
0
        public void Execute_Step(string step, int count) // Executes steps for all workflow routines
        {
            try
            {
                Log_Text_Box.AppendText(DateTime.Now.ToString("[M/d/yyyy @ h:mm:stt] ") + "Executing step: " + step + "\r\n");

                if (!step.Substring(0, 2).Equals("//"))
                {
                    SendKeys.Send(step);
                    SendKeys.Send("{ENTER}");
                }
                else
                {
                    WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
                    wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath($"{step}")));

                    IWebElement clickEvent = driver.FindElement(By.XPath($"{step}"));

                    clickEvent.Click();
                }
            }
            catch (WebDriverException) // Retries up to three times before quitting
            {
                count++;
                if (count == 4)
                {
                    Log_Text_Box.AppendText(DateTime.Now.ToString("[M/d/yyyy @ h:mm:stt] ") + $"Step {step} has failed." + "\r\n");
                    driver.Quit();
                    return;
                }
                else
                {
                    Log_Text_Box.AppendText(DateTime.Now.ToString("[M/d/yyyy @ h:mm:stt] ") + $"Could not execute step: {step}." + "\r\n");
                    Log_Text_Box.AppendText(DateTime.Now.ToString("[M/d/yyyy @ h:mm:stt] ") + $"Attempting step: {step} again." + "\r\n");
                    Execute_Step(step, count);
                }
            }
        }
Пример #4
0
        public void Driver_Setup() // Sets up web driver and logs user in
        {
            string webURL = "https://example.com";

            ChromeDriverService service = ChromeDriverService.CreateDefaultService();

            service.HideCommandPromptWindow = true;

            ChromeOptions options = new ChromeOptions();

            options.AddArgument("disable-infobars");
            options.AddArgument("incognito");
            options.AddArgument("start-maximized");

            driver = new ChromeDriver(service, options);

            driver.Navigate().GoToUrl(webURL);

            try
            {
                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
                wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath("//*[@id='loginUserName']")));

                IWebElement login       = driver.FindElement(By.XPath("//*[@id='loginUserName']"));
                IWebElement password    = driver.FindElement(By.XPath("//*[@id='loginPass']"));
                IWebElement loginButton = driver.FindElement(By.XPath("//button[contains(text(), 'Log In')]"));

                login.SendKeys(smartITUser);
                password.SendKeys(smartITPassword);
                loginButton.Click();
            }
            catch (WebDriverException)
            {
                Log_Text_Box.AppendText(DateTime.Now.ToString("[M/d/yyyy @ h:mm:stt] ") + "Could not find login fields." + "\r\n");
                driver.Quit();
            }
        }
Пример #5
0
 private void Clear_Log_Button_Click(object sender, EventArgs e)
 {
     Log_Text_Box.Clear();
 }