![](/img/trans.png)
[英]Why am I getting a runtime error when I try to convert from an ImageSource to a BitmapImage?
[英]Getting an Error When I Try To Output What Was Chosen From a Dropdown
所以我有一個方法,我從下拉菜單中獲取一個隨機項目。 我想 output 選擇的項目,所以我知道如果測試失敗,選擇了哪個選項。 這是我的方法:
public static void DropdownSelectRandomOption(IWebElement dropDown)
{
dropdown. Click();
Random rnd = new Random();
var selectElement = new SelectElement(dropDown);
int itemCount = selectElement.Options.Count;
var itemChosen = selectElement.SelectByIndex(rnd.Next(0, itemCount));
Console.WriteLine($"The item chosen from the dropdown is: {itemChosen}");
itemChosen.Click();
dropDown.Click();
}
我在var itemChosen
的行上遇到了一個錯誤,它說Cannot Assign Void to an implicitly-typed variable
我在這里做錯了什么?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.