如何更换方法点击Selenium C#?

时间:2016-06-03 10:21:43

标签: c# selenium

在我的网页

<button class="btn btn-small dropdown-toggle" data-toggle="dropdown">
                       Name Button
<span class="caret"/>
</button>
<ul class="dropdown-menu">
<input id="---" type="hidden" value="---"/>
<li>
<label class="Styledcheckbox">
<div class="Styledcheckbox">
Tranche A                                         
</label>
</li>
 .....

当我点击按钮&#34; 名称按钮&#34;弹出菜单出现,但当我使用方法点击弹出菜单上的selenium方法时,它将被关闭,在这种情况下,我无法检测弹出窗口中的文本。

IWebElement element = null;
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
element = wait.Until(ExpectedConditions.ElementToBeClickable(locator));
element.Click();

如何替换此代码,弹出菜单保持打开状态,直到我从弹出窗口中选择一个值。

我也试过了:

 Actions builder = new Actions(driver);
 IWebElement element = null;
 WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
 element = wait.Until(ExpectedConditions.ElementToBeClickable(locator));
 builder.MoveToElement(element).Release();

0 个答案:

没有答案