I'm trying to click an element by data-bind attribute and using the FindsBy attribute. I also tried to implement it by following this tutorial , but could not really get it work.
is it possible to use Findsby? something like this
[FindsBy(How = How.Databind, Using = "click: AddAttachment ")]
public IWebElement btnUpload{ get; set;}
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']")]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.