我使用基于chrome网络的应用程序。我们使用bootstrap,这使得简单地右键单击dev工具中的元素并获取其xpath或cssselector变得更加困难。
以下是我试图点击的按钮的代码:
div class="pull-right"
button data-bind="click: $root.update, enable: !($root.isLoading() || $root.isRunning()) && workOrderId() > 0, css: {'disabled' : ($root.isLoading() || $root.isRunning() || workOrderId() === 0) }" class="btn btn-primary btn-sm selectorgadget_selected" style="opacity: 0.6;">Calculate</button> == $0
IWebElement applyCalculate = driver.FindElement(By.CssSelector(&#34; .btn-sm&#34;));
IWebElement applyCalculate = driver.FindElement( By.CssSelector( ".btn-sm" ) );
try
{
applyCalculate.Click();
{
};
}
catch (Exception)
{
{
};
}
我可以使用Classname,cssselector,xpath,几乎任何可能在这一点上起作用的东西。有任何想法吗?找到元素,但不点击
答案 0 :(得分:0)
<强> CODE 强>:
<div class="form-group form-group-sm" data-bind="visible:
!$root.isCollapsed() && !$root.isLocked()"> == $0
::before
<div class="pull-right">
<button data-bind="click: $root.update, enable:!
($root.isLoading() || $root.isRunning()) && workOrderId() > 0,
css: {'disabled' : ($root.isLoading() || $root.isRunning() ||
workOrderId() === 0) }" class="btn btn-primary btn-sm" style=
"opacity: 0.6;">Calculate</button>
</div>
</div>
<强> SCRIPT 强>:
IWebElement applyCalculate = driver.FindElement(By.ClassName(".btn-sm"));
try
{
if (applyCalculate != null)
{
applyCalculate.Click();
applyCalculate.Click();
{
};
}
else
{
{
};
}
}
catch (Exception)
{
}