Esempio n. 1
0
 /// <summary>
 /// Quit current session. Remove app/remove session
 /// </summary>
 /// <param name="driver"></param>
 internal static void QuitSession(WinDriver driver)
 {
     using (var httpClient = new HttpClient())
     {
         var responseMessage = httpClient.DeleteAsync($"{driver.Uri}/session/{ driver.Guid }").Result;
         var result          = responseMessage.Content.ReadAsStringAsync().Result;
         Console.WriteLine(result);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Send request to find element in current session (window)
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="strategy"></param>
        /// <returns></returns>
        internal static Guid?FindElement(WinDriver driver, FindElementStrategy strategy)
        {
            using (var httpClient = new HttpClient())
            {
                var json = JsonConvert.SerializeObject(strategy);
                var data = new StringContent(json, Encoding.UTF8, "application/json");

                var responseMessage = httpClient.PostAsync($"{driver.Uri}/session/{driver.Guid}/element", data).Result;
                var result          = JsonConvert.DeserializeObject <Element>(responseMessage.Content.ReadAsStringAsync().Result);

                return(result.Id);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Send request which initialize new session
        /// </summary>
        /// <param name="driver"></param>
        /// <returns></returns>
        internal static string StartSession(WinDriver driver)
        {
            using (var httpClient = new HttpClient())
            {
                var launchSession = new LaunchSession
                {
                    App = driver.Options.App,
                    AppStartUpTimeOut   = driver.Options.AppStartUpTimeOut,
                    ImplicitWaitTimeout = driver.Options.ImplicitWaitTimeout
                };

                var json = JsonConvert.SerializeObject(launchSession);
                var data = new StringContent(json, Encoding.UTF8, "application/json");

                var responseMessage = httpClient.PostAsync($"{driver.Uri}/session", data).Result;
                var result          = responseMessage.Content.ReadAsStringAsync().Result;
                return(result.Replace("\"", string.Empty));
            }
        }
Esempio n. 4
0
 public double GetResult()
 {
     return(double.Parse(WinDriver.GetDriver().FindElementById("CalculatorResults").GetAttribute("Name").Replace("Display is ", string.Empty)));
 }
Esempio n. 5
0
 public string GetCalculatorExpression()
 {
     return(WinDriver.GetDriver().FindElementById("CalculatorExpression").GetAttribute("Name").Replace("Expression is ", string.Empty));
 }
Esempio n. 6
0
 public void ClickClearButton()
 {
     WinDriver.GetDriver().FindElementByName("Clear").Click();
 }
Esempio n. 7
0
 public void ClickEqualsButton()
 {
     WinDriver.GetDriver().FindElementByName("Equals").Click();
 }
Esempio n. 8
0
 public void ClickMultiplyByButton()
 {
     WinDriver.GetDriver().FindElementByName("Multiply by").Click();
 }
Esempio n. 9
0
 public void ClickSqrtRootButton()
 {
     WinDriver.GetDriver().FindElementByName("Square root").Click();
 }
Esempio n. 10
0
        private void ClickDigit(int digit)
        {
            var id = string.Format(numButtonId, digit);

            WinDriver.GetDriver().FindElementById(id).Click();
        }
Esempio n. 11
0
 public static void Cleanup()
 {
     WinDriver.CloseWindows();
 }