具有.NET的Selenium:无效的元素状态:元素当前不可交互,并且可能无法操纵 [英] Selenium with .NET: invalid element state: Element is not currently interactable and may not be manipulated
问题描述
我正在尝试从中读取一个值.这是HTML代码:
I am trying to read a value from . Here is the HTML code:
<select name="user_type" id="user_type" class="select">
<option value="0">Select</option>
<option value="1"> Admin </option>
<option value="1"> Agent </option>
<option value="1"> Butler </option>
<option value="1"> Ops </option>
</select>
这是我使用.NET在Selenium中实现的代码:
This is the code I implemented in Selenium using .NET:
query_UserType = driver.FindElement(By.Id("user_type"));
driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30));
query_UserType.Clear();
query_UserType.Click();
query_UserType.SendKeys(" Agent ");
string str_myEle2 = query_UserType.GetAttribute("value");
Console.WriteLine("New User Type is: " + str_myEle2);
在行:
query_UserType.Clear();
我不知道如何解决此问题.请帮忙.谢谢
I have no clue how can I get this fixed. Please help. Thanks
推荐答案
如果仅在Chrome浏览器中出现此问题,请删除以下命令:
If this issue appear with Chrome browser only, remove the following command:
query_UserType.Clear();
我在使用Chrome时遇到了同样的问题,并且在清除了清除命令后,该问题已得到解决.
I faced the same problem with Chrome and it is fixed after removing clear command.
如果您确实要从文本框中删除文本,请尝试使用机械手类或任何其他键盘模拟器,然后按退格"/删除"按钮.
In case of you really want to delete a text from a text box, try using robot class or any other keyboard simulator and press "backspace"/"delete" button.
这篇关于具有.NET的Selenium:无效的元素状态:元素当前不可交互,并且可能无法操纵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!