Ejemplo n.º 1
0
        public static void reloadContext(FirefoxDriver d)
        {
            while (!ProtectionContext.Protect())
            {
                ;
            }

            Console.WriteLine("reloading context");
            while (true)
            {
                try {
                    List <IWebElement> chatdata = d.FindElement(By.Id("chatList")).FindElements(By.TagName("div")).ToList();
                    messageDivSize = chatdata.Count;
                    foreach (IWebElement we in chatdata)
                    {
                        if (Int32.Parse(we.GetAttribute("id").Substring(we.GetAttribute("id").LastIndexOf('_') + 1)) > currentMessage)
                        {
                            currentMessage = Int32.Parse(we.GetAttribute("id").Substring(we.GetAttribute("id").LastIndexOf('_') + 1));
                        }
                    }
                    Console.WriteLine("got here");
                    break;
                } catch (Exception shoehorn) {
                    Console.WriteLine(shoehorn.Message);
                }
            }
            Console.WriteLine("reloading context complete");
            if (d.FindElement(By.Id("audioButton")).GetAttribute("class").ToLower() == "button")
            {
                d.FindElement(By.Id("audioButton")).Click();
            }

            ProtectionContext.Free();
        }
Ejemplo n.º 2
0
        public static void sendMessage(string text, FirefoxDriver d, bool protect = true)
        {
            if (protect)
            {
                while (!ProtectionContext.Protect())
                {
                    ;
                }
            }

            if (isChatting(d))
            {
                d.FindElement(By.Id("inputField")).SendKeys(text);
                d.FindElement(By.Id("submitButton")).Click();
                try { Thread.Sleep(500); } catch (Exception e) { }
            }

            if (protect)
            {
                ProtectionContext.Free();
            }
        }