硒按钮点击在火狐中失败.但仅在使用网络驱动程序时
本文关键字:网络 驱动程序 失败 按钮 火狐 | 更新日期: 2023-09-27 17:57:11
这是我的困境...我有一个按钮在使用 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或手动单击。 什么也没发生。如果我手动打开火狐,该按钮是可点击的。
我试过这个:
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">
还尝试在火狐中禁用图像和/或css。
有什么想法吗?
您需要从元素 css 中删除"禁用:禁用"。在那之后你应该一切都准备好