这是我的困境...... 我在使用WebDriver打开的浏览器窗口中有一个无法点击的按钮。
按钮:
<div class="ribbon-section">
<span class="section-title" data-bind="text: title">Email</span>
<div class="layout" data-bind="css: { 'vertical': isVertical ,layout:true}">
<div id="email-btn" class="ribbon-control ribbon-button ribbon-button-large" data-bind="attr: { id: id }, css: { disabled: disabled, 'ribbon-button-large': size() == 'large', 'ribbon-button-small': size() == 'small', 'ribbon-button-medium': size() == 'medium' }, click: onClick">
<img class="ribbon-icon ribbon-normal" data-bind="attr: { src: imgNormal }, visible: !disabled()" src="/_layouts/15/klscript/content/images/ribbon/normal/email-link.png" style="">
<img class="ribbon-icon ribbon-disabled" data-bind="attr: { src: imgDisabled }, visible: disabled()" src="/_layouts/15/klscript/content/images/ribbon/disabled/email-link.png" style="display: none;">
<span class="control-title" data-bind="html: title">Email Link</span>
<span class="control-help" data-bind="text: tooltip">Email Link</span>
</div>
</div>
</div>
并不是WebDriver无法找到元素或类似的东西。无法通过WebDriver或手动单击该按钮。什么都没发生。 如果我手动打开Firefox,则可以单击该按钮。
我试过这个:
driver.FindElement(By.Id("email-btn")).Click();
和此:
IWebElement emailBtn = driver.FindElement(By.Id("email-btn"));
Actions act = new Actions(driver);
act.Click(emailBtn);
和此:
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
js.ExecuteScript("document.getElementById('email-btn').click()");
将它与另一个没有问题的按钮相比较,除了Id之外,我发现它们是相同的:
<div id="email-btn" class="ribbon-control ribbon-button ribbon-button-large" data-bind="attr: { id: id }, css: { disabled: disabled, 'ribbon-button-large': size() == 'large', 'ribbon-button-small': size() == 'small', 'ribbon-button-medium': size() == 'medium' }, click: onClick">
<div id="download-item-btn" class="ribbon-control ribbon-button ribbon-button-large" data-bind="attr: { id: id }, css: { disabled: disabled, 'ribbon-button-large': size() == 'large', 'ribbon-button-small': size() == 'small', 'ribbon-button-medium': size() == 'medium' }, click: onClick">
还尝试在Firefox中禁用图像和/或css。
有什么想法吗?
答案 0 :(得分:0)
您需要从元素css中删除'disabled:disabled'。你应该在那之后完成所有工作