angularjs - 我正在自动化一个角度注册表单,我有一个下拉框,其 id 是 span 以及如何根据用户输入选择选项
问题描述
这是我的代码:
WebElement id1=driver.findElement(By.cssSelector(".mat-select-placeholder"));
Select drid = new Select(id1);
drid.selectByIndex(1);
我得到错误元素被选择但它是跨度的。
如何解决这个问题?
HTML:
<mat-form-field id="select-shyam"> <mat-label>Favorite food</mat-label> <mat-select id="select-parth"> <mat-option *ngFor="let food of foods; let index = index" [value]="food.value" id="{{'select-parth-' + index}}"> {{food.viewValue}} </mat-option> </mat-select> </mat-form-field> <br> <br>
错误 :
org.openqa.selenium.support.ui.UnexpectedTagNameException:元素应该是“select”但是“mat-select”构建信息:版本:'3.10.0',修订:'176b4a9',时间:'2018-03- 02T19:10:56.039Z' 系统信息:主机:'GTJPCPU07',ip:'192.168.40.160',os.name:'Windows 10',os.arch:'amd64',os.version:'10.0',java .version: '1.8.0_161' 驱动程序信息: driver.version: org.openqa.selenium.support.ui.Select.(Select.java:47) at EtaCore.Setup_Clear_Roles.addnewwrole(Setup_Clear_Roles.java:118) 未知sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)
解决方案
推荐阅读
- angular - 复杂的可观察数组排序
- matlab - 如何按给定列中的值拆分表?
- java - 如何阻止围绕内部运行异步 rxjava 任务的方法编写的 spring 方面的执行,直到完成 rxjava 可观察任务?
- c# - 使用 semaphoreslim 取消异步任务需要很长时间
- python - 如何在忽略特殊字符的字符串后查找接下来的 9 个字符?
- c - 如何创建一个从每秒变量中删除 1 的计时器
- ruby-on-rails - 如何在 Rails 4 中提供 HSTS 支持
- python - python - 如何在python中的.json文件中以给定格式从.csv文件中提取数据?
- google-analytics - 访问报告 API 的 Google 身份验证要求
- dynamics-crm - $batch 请求 - 与逐个执行的请求相比,它们是否提供客户端性能加速