Example #1
0
        void PlayMessagesFromQue()
        {
            while (true)
            {
                Thread.Sleep(200);

                if (Globals.messagesQue.Count != 0)            // если есть сообщения
                {
                    if (synth.State == SynthesizerState.Ready) // если ничего не произносится
                    {
                        if (Globals.IsReceiveMessages)
                        {
                            var voice = Globals.messagesQue[0].VoiceName;

                            try
                            {
                                installedVoices.First(x => x.VoiceInfo.Name == voice);
                            }
                            catch
                            {
                                Globals.messagesQue.RemoveAt(0);
                                continue;
                            }



                            var text = Globals.messagesQue[0].Text;

                            //MessageBox.Show(text);

                            if (text.StartsWith(string.Format("{0} говорит: ", Globals.Username)))
                            {
                                Debug.WriteLine("Main: удалено сообщение, ник был тот же");
                                Globals.messagesQue.RemoveAt(0);
                                continue;
                            }

                            var rate   = Globals.messagesQue[0].Rate;
                            var volume = Globals.messagesQue[0].Volume;

                            synth.SelectVoice(voice);
                            synth.Rate   = (int)rate;
                            synth.Volume = (int)volume;

                            Debug.WriteLine("Main: начато произнесение полученого текста");
                            synth.SpeakAsync(text);
                            //MessageBox.Show(String.Format("{0}:{1}:{2}:{3}", text, rate, volume, voice));

                            Globals.messagesQue.RemoveAt(0);
                        }
                        else
                        {
                            Globals.messagesQue.Clear();
                        }
                    }
                }
            }
        }
Example #2
0
        public void BatchTest()
        {
            int beginResults = GetResultsCountBefore();

            string input  = Path.GetFullPath("TestFolder/Input/InputFile.png");
            string input2 = Path.GetFullPath("TestFolder/Input/InputBatchFile.png");

            _driver.Navigate()
            .GoToUrl("https://localhost:5001/Upload/Batch");
            IWebElement uploader = _driver.FindElement(By.Id("batch-input"));

            uploader.SendKeys(input + "\n" + input2);

            //Press upload
            IWebElement upload = _driver.FindElement(By.Id("confirm"));

            upload.Click();

            Thread.Sleep(2000);

            Assert.Equal("https://localhost:5001/", _driver.Url);

            _driver.Navigate()
            .GoToUrl("https://localhost:5001/Results");
            IWebElement tableBody = _driver.FindElement(By.Id("results-table")).FindElement(By.TagName("tbody"));

            System.Collections.ObjectModel.ReadOnlyCollection <IWebElement> rows = tableBody.FindElements(By.TagName("tr"));
            Assert.Equal(beginResults + 1, rows.Count);

            //Goto details and get img count
            rows.First().FindElement(By.ClassName("btn-actions")).Click();
            Thread.Sleep(200);
            Assert.Contains("Results/Details", _driver.Url);
            Assert.Equal(2, _driver.FindElements(By.TagName("img")).Count);
        }
Example #3
0
        public string GetAudioEndpoint()
        {
            Guid guid = ((DirectSoundOut)aout).Device;

            System.Collections.ObjectModel.ReadOnlyCollection <DirectSoundDevice> list = DirectSoundDeviceEnumerator.EnumerateDevices();
            DirectSoundDevice dsd = list.First(x => x.Guid == guid);

            return(dsd.Description);
        }
Example #4
0
 public static Customer GetCustomer(string customerDisplaysName)
 {
     try
     {
         ServiceContext context = QuickBookConnection.GetDataServiceContext();
         var            service = new DataService(context);
         Intuit.Ipp.QueryFilter.QueryService <Customer> queryServiceForCustomer    = new Intuit.Ipp.QueryFilter.QueryService <Customer>(context);
         System.Collections.ObjectModel.ReadOnlyCollection <Customer> customerList = queryServiceForCustomer.ExecuteIdsQuery("select * from customer");
         Customer customer = customerList.First <Customer>(cust => cust.DisplayName == customerDisplaysName);
         return(customer);
     }
     catch (Intuit.Ipp.Exception.IdsException ex)
     {
         throw;
     }
 }
Example #5
0
        /// <summary>
        /// Create IWebElement using  Element attributes type and Element attribute.
        /// </summary>
        /// <param name="attributeType">string : Type of property</param>
        /// <param name="attribute">string : Property value</param>
        /// <returns>Instance of IwebElement</returns>
        private IWebElement GetElementByAttribute(string attributeType, string attribute)
        {
            try
            {
                switch (attributeType.ToLower())
                {
                    case "cssselector":
                        _testObjects = Driver.FindElements(By.CssSelector(attribute));
                        break;
                    case "css":
                        _testObjects = Driver.FindElements(By.CssSelector(attribute));
                        break;
                    case "name":
                        _testObjects = Driver.FindElements(By.Name(attribute));
                        break;
                    case "id":
                        try
                        {
                            _testObjects = Driver.FindElements(By.Id(attribute));
                        }
                        catch (NullReferenceException)
                        {
                            GetElementByAttribute("css", "#" + attribute);
                        }
                        break;
                    case "linktext":
                    case "text":
                    case "link":
                        _testObjects = Driver.FindElements(By.LinkText(attribute));
                        break;
                    case "xpath":
                        _testObjects = Driver.FindElements(By.XPath(attribute));
                        break;
                    case "partiallinktext":
                        _testObjects = Driver.FindElements(By.PartialLinkText(attribute));
                        break;
                    case "tag":
                    case "tagname":
                    case "html tag":
                        _testObjects = Driver.FindElements(By.TagName(attribute));
                        break;
                    case "class":
                        _testObjects = Driver.FindElements(By.ClassName(attribute));
                        break;
                    case "classname":
                        _testObjects = Driver.FindElements(By.ClassName(attribute));
                        break;
                    default:
                        throw new Exception("Locator Type :\"" + attributeType + "\" is undefined");
                }

                if (DebugMode.Equals("true", StringComparison.OrdinalIgnoreCase))
                {
                    Console.WriteLine("Found " + _testObjects.Count + " objects matching to locator " + attributeType + "=" + attribute);
                }

                Utility.SetVariable("ElementCount", _testObjects.Count.ToString());

                if (_testObjects.Count.Equals(0))
                {
                    _testObject = null;
                    throw new NoSuchElementException();
                }

                if (_testObjects.Count.Equals(1))
                {
                    _testObject = _testObjects.First();
                    return _testObject;
                }

                //Variable to store if object is currently displayed
                bool isObjectDisplayed = false;
                _firstObject = _testObjects.First();

                //For each element, check if it is displayed. If yes, return it
                int counter = 0;
                foreach (IWebElement element in _testObjects)
                {
                    counter = counter + 1;

                    //If no displayed object could be located, store first element to test object by default
                    if (!Property.IsRecoveryRunning)
                    {
                        _testObject = _testObjects.First();
                    }

                    try
                    {
                        isObjectDisplayed = element.Displayed;

                        //Print on console about object displayed status
                        if (DebugMode.Equals("true", StringComparison.OrdinalIgnoreCase))
                        {
                            Console.WriteLine("Object position: " + counter + ", displayed= " + isObjectDisplayed);
                        }

                        //Return if object is displayed
                        if (isObjectDisplayed)
                        {
                            HightlightObject(element);
                            _testObject = element;
                            return _testObject;
                        }
                    }
                    catch (Exception displayCheck)
                    {
                        Console.WriteLine("Failed to check display attribute of element at position: " + counter +
                                          "Error:" + displayCheck.Message);
                    }

                }

                //During Browser recovery,we are not supposed to return testobject if it is not displayed on page.
                if (Property.IsRecoveryRunning && !isObjectDisplayed)
                {
                    return null;
                }

                // Xpath Generation.
                if (Utility.GetVariable("forcexpath").ToLower().Equals("true"))
                {
                    string xpathString = getEquivalentXpath(_testObject);
                    if (xpathString != null)
                    {
                        _testObject = null;
                        _testObject = Driver.FindElement(By.XPath(xpathString));
                        return _testObject;
                    }
                }
                return null;
            }
            catch (NoSuchElementException)
            {
                return null;
            }
            catch (InvalidOperationException)
            {
                return GetSingleElementByAttribute(attributeType, attribute);
            }
        }