예제 #1
0
        void GetBentoForTheDay(Bento bt)
        {
            string dateString = bt.BentoDate.ToString("yyyy/MM/dd");

            dateString    = dateString.Replace("/", "%2F"); // URL encoding
            webDriver.Url = String.Format("https://www.obentonet.jp/item_list.html?from={0}&to={0}", dateString);
        }
예제 #2
0
        /// <summary>
        /// Finds and clicks the order button. This assumes each order option has a different price.
        /// </summary>
        void AddBentoToCart(Bento bento)
        {
            var buttons = webDriver.FindElements(By.XPath($@"//input[@class='item_price' and @value='{bento.Price}']/following-sibling::img[@alt='買い物かごに入れる']"));

            if (buttons.Count() != 1)
            {
                throw new Exception("Cannot determine which button to submit the order.");
            }

            IWebElement cartBtn = buttons.First();

            if (cartBtn.GetAttribute("src").Contains("button_cart_ordered"))
            {
                throw new Exception("The specified item seems to be ordered already.");
            }
            cartBtn.Click();
        }
예제 #3
0
        void CheckInput(Bento bento)
        {
            int i = 0;

            while (webDriver.Url != "https://www.obentonet.jp/cart_seisan.html")
            {
                var task = Task.Delay(500);
                task.Wait();
                ++i;
                if (i == 10)
                {
                    throw new Exception("Timeout occurred for cart_seisan");
                }
            }

            if (!webDriver.PageSource.Contains(bento.PriceStr))
            {
                throw new Exception("Bento type might be mismatched.");
            }

            IWebElement btn = webDriver.FindElement(By.XPath("//input[@alt='入力内容を確認する']"));

            btn.Click();
        }