【发布时间】:2016-11-10 09:39:18
【问题描述】:
我正在使用 Selenium Webdriver 和 C# 绑定,并尝试从旧的 FirefoxDriver(FF 47 之前)切换到新的 Marionette driver(FF47 及更高版本),并且在一些似乎出现的初期问题之后它运行良好通过发布Selenium 2.53.1 和FF 47.0.1 进行修复。
现在唯一的问题是在选择标签下选择选项标签似乎有问题。以下代码适用于我正在测试的所有其他浏览器(FF dropdownSelect 函数。选择 IWebElement 和要搜索的文本。这是函数定义:
public static void dropdownSelect(IWebDriver driver, IWebElement inObject, string inText)
我已经尝试使用 SelectElement() 类,就像我在所有其他浏览器中一样
select = new SelectElement(inObject);
//select the matching element
select.SelectByText(inText);
我还尝试获取选项的集合并使用Click() 滚动浏览集合:
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
ReadOnlyCollection<IWebElement> optDropdown;
optDropdown = inObject.FindElements(By.TagName("option"));
foreach (IWebElement thsItem in optDropdown)
{
//check for matching text
if (thsItem.Text == inText)
{
// 1/4 second wait
Thread.Sleep(250);
thsItem.Click()
//exit foreach loop
break;
}
}
然后点击javascript 代替thsItem.Click() 一段代码
//click option element
js.ExecuteScript("arguments[0].click();", thsItem);
从未选择任何内容,也不会引发错误或异常。它只是继续快乐地前进,没有选择任何东西
是我做错了什么,还是新的 Marionette 驱动程序仍在解决这个问题?
【问题讨论】:
-
你有同样的工作吗?我面临着完全相同的问题,我已经尝试了所有我能找到的解决这个问题的方法,任何帮助都会很棒
标签: javascript c# selenium firefox-marionette