TA的每日心情 | 奋斗 2015-12-28 18:27 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]测试小兵
|
大家好,我是selenium的新手,现在遇到一个关于如何定位下拉菜单的问题。
具体html 如下:
<select class="form-control ng-pristine ng-untouched ng-valid" ng-model="gus.curr_gu">
<option value="? object:null ?"></option>
<option class="ng-binding ng-scope" ng-repeat="gu in gus.gus | orderBy:'guname'" value="Shanghai">Shanghai</option>
<option class="ng-binding ng-scope" ng-repeat="gu in gus.gus | orderBy:'guname'" value="Beijing">Beijing</option>
</select>
我用了CssSelector的定位方法, 麻烦大家帮忙看看这个有什么问题啊,怎么样可以正常定位到这个元素呢,非常感谢!
SelectElement SelectGU = new SelectElement(driver.FindElement(By.CssSelector("select.form-control.ng-pristine.ng-untouched.ng-valid")));
SelectGU.SelectByValue("Shanghai");
一直报错,下面是exception detail:
OpenQA.Selenium.NoSuchElementException was unhandled
HResult=-2146233088
Message=Unable to locate element: {"method":"css selector","selector":"select.form-control.ng-pristine.ng-untouched.ng-valid"}
Source=WebDriver
StackTrace:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementByCssSelector(String cssSelector)
at OpenQA.Selenium.By.<>c__DisplayClass1e.<CssSelector>b__1c(ISearchContext context)
at OpenQA.Selenium.By.FindElement(ISearchContext context)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by)
at DownloadNoGoList.Main(String[] args) in c:\CIO Project\Specflowstudy\1225\selenium\DownloadNoGoList\DownloadNoGoList\Program.cs:line 57
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
|
|