[英]How to click on a input button in a non static page (webbrowser c#)?
[英]How to click on <input> type button C#
我试图通过 .css/by classname
但不幸的是,它没有用...
<div class="col-xs-12">
<input type="submit" name="commit" value="save" class="pp-btn pp-btn-primary w-70 save-item-description" data-disable-with="saving...">
<a class="pp-btn pp-btn-danger w-70" data-disable-with="..." data-target="#item-ebay_details" data-remote="true" href="/items/468056.html?partial=ebay_details">cancel</a>
</div>
我需要Click()
,最好按类名跟踪它...
您可以使用 xpath 选择器按类名查找:
driver.FindElement(By.Xpath(//input[@class='submit']);
请记住,您的元素在引用它时可能尚未准备好/呈现/可点击,这就是为什么您需要使用 IMPLICIT 或 EXPLICIT 等待(它有很好的文档记录,请搜索它)
您可以通过这种方式等待元素可点击:
new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementExists((By.XPath(//input[@class='submit']))));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.