c# - Selenium 查找选择节点的 xpath
问题描述
我正在尝试为以下内容生成 xpath:
<select data-bind="options: PrinterLabelTypes, optionsValue: 'value', optionsText:
'value', value: NewPrinterLabelTypeText, optionsCaption: GetText('SelectLabelType')">.
<option value="">Choose Printer Label Type...</option><option
value="Batch">Batch</option><option value="Despatch">Despatch</option>
</select>
我尝试了以下方法:
//select[@data-bind='value: NewPrinterLabelTypeText']
但我没有得到任何回报。我错过了什么吗。有没有办法使用上面的格式来做到这一点?
解决方案
contains
当您的定位器使用部分属性值时,您必须使用。
//select[contains(@data-bind,'value: NewPrinterLabelTypeText')]
推荐阅读
- angular - 每次更改后从选择元素中清除所选值
- arrays - 快速更新数组的元素值
- javascript - 生成图标
- python - 我可以在 python 3 中的字符串中添加时间延迟吗?
- java - Java Mail API 会降低应用程序的性能。有没有办法改进它?
- triggers - 根据是否在插入和更新上运行顶点触发器运行额外的代码块?
- r - arulesSequences 中的 cspade 函数引发连接错误
- cmake - 如何获取当前构建类型的所有编译标志
- scala - Spark - 删除两个数组类型列之间的相交元素
- node.js - 使用 Node 和 Sails.JS 的端点别名?