簡體   English   中英

無法從 Selenium C# webdriver 的多選下拉列表(組合框)中選擇值

[英]Not able to select value from multi select drop down (Combo box) in Selenium C# webdriver

我有 div 類,在那個 UL 元素下,在那個 LI 元素下,在那個 LI 中有我想要選擇的選項值。 這些沒有任何 id、cssselector、linktext 或 xpath。 如何選擇它們?

我找到了以下選擇動態下拉菜單的答案。

            driver.FindElement(By.Id("language")).Click();   
            IList<IWebElement> cartItems = driver.FindElements(By.CssSelector(".active-result"));
            string[] arr = new string[] { "Breton", "Catalan" };

            int i = 1;
            int j = 0;
            foreach (IWebElement cartItem in cartItems)
            {
                var value = cartItem.Text;
                if(value== arr[j])
                {
                    this.driver.FindElement(By.XPath("//*[@id='ChildLanguages_chosen']/div/ul/li["+i+"]")).Click();
                    j++;
                }
                i++;
            }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM