[英]Find Elements by data-bind [Findsby]
I'm trying to click an element by data-bind attribute and using the FindsBy attribute. 我正在尝试通过数据绑定属性并使用FindsBy属性单击一个元素。 I also tried to implement it by following this tutorial , but could not really get it work. 我还尝试通过遵循本教程来实现它,但是并不能真正使其起作用。
is it possible to use Findsby? 有可能使用Findsby吗? something like this 像这样的东西
[FindsBy(How = How.Databind, Using = "click: AddAttachment ")]
public IWebElement btnUpload{ get; set;}
html html
<button type="button" class="btn btn-link" data-bind="click: AddAttachment ">Upload</button>
Not sure how your setup is but mine would look like this: 不确定您的设置如何,但是我的看起来像这样:
[FindsBy(How = How.XPath, Using = "//button[contains(text(), 'Upload')]")]
private readonly IWebElement _upload = null;
Then create a method to use it. 然后创建一个使用它的方法。
public void ClickUpload()
{
Browser.Click(_upload);
}
如果data-
属性的值查找,则可以使用以下命令:
[FindsBy(How = How.XPath, Using = "//button[@data-bind = 'click: AddAttachment']")]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.