【发布时间】:2019-02-20 22:10:10
【问题描述】:
我正在为一个收集用户输入的网站(使用 node 和 Angular 实现)创建一个测试套件。一些输入是具有编辑功能的文本框的形式(类似于堆栈溢出中使用的这个)。创建可编辑框的代码是
<div id="mceu_30" class="mce-edit-area mce-container mce-panel mce-stack-layout-item" hidefocus="1" tabindex="-1" role="group" style="border-width: 1px 0px 0px;">
<iframe id="ui-tinymce-9_ifr" frameborder="0" allowtransparency="true" title="Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help" style="width: 100%; height: 100px; display: block;"></iframe>
<html> <head><style>...</style></head> <body id="tinymce" class="mce-content-body " data-id="ui-tinymce-1" contenteditable="true" spellcheck="false"><p><br data-mce-bogus="1"></p></body> </html>
</div>
为简单起见,我删除了所有部分。
我正在使用 Geb/Spock 框架进行测试。检查上述元素的具体代码是
withFrame(OppBackgroundBox){$("body", id:"tinymce") << Background }
其中 'Background' 是之前在测试脚本中定义的字符串,而 OppBackgroundBox 是定义为的页面元素
OppBackgroundBox{$(By.xpath('//iframe[@title="Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help"]'),0)}
我通过标题来识别元素,因为框架的 id 会随着浏览器的变化而变化(//[@id="ui-tinymce-9_ifr"] 对于 Mozilla,但 //[@id="ui-tinymce-1_ifr" 适用于 Chrome)。
在 Chrome 中运行测试时一切正常,但是,当使用 Firefox(Mac 为 65.0.1)时,我收到以下错误
条件失败并出现异常:
withFrame(OppBackgroundBox){$("body", id:"tinymce") OppBackgroundBox: geb.navigator.NonEmptyNavigator
org.openqa.selenium.WebDriverException:[异常...“组件 返回失败代码:0x80004005 (NS_ERROR_FAILURE) [nsITextInputProcessor.beginInputTransactionForTests]" nsresult: “0x80004005 (NS_ERROR_FAILURE)”位置:“JS 框架 :: chrome://marionette/content/event.js :: getTIP_ :: line 429" 数据: 否]构建信息:版本:'3.141.59',修订:'e82be7d358',时间: '2018-11-14T08:17:03' 系统信息:主机:'Carless-MacBook-Pro.local', ip: 'fe80:0:0:0:c3c:ed6e:6d05:b45d%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.3', java.version: '11.0.1' 驱动信息: org.openqa.selenium.firefox.FirefoxDriver 功能 {acceptInsecureCerts: true, browserName: firefox, browserVersion: 65.0.1, javascriptEnabled: true, moz:accessibilityChecks: false, moz:geckodriverVersion: 0.24.0, moz:headless: false, moz:processID: 30057, moz:profile: /var/folders/10/vbth59yn0v1..., moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: 假,moz:webdriverClick:真,pageLoadStrategy:正常,平台: MAC,平台名称:MAC,平台版本:18.2.0,可旋转:假, setWindowRect:true,strictFileInteractability:false,超时: {隐式:0,pageLoad:300000,脚本:30000}, unhandledPromptBehavior:解雇并通知} 会话 ID: 62b25df0-58cf-db4f-9d3c-12a1b12820ce
在 CreateProgramProjectOpp.Publish 机会: '#TitleData'(CreateProgramProjectOpp.groovy:195)
(其中 195 指的是 withFrame(OppBackgroundBox){$("body", id:"tinymce") 行代码)
上面的错误信息有点乱码,但是关联到OppBackgroundBox的是信息
pages.app.OpportunitiesAdminCreatePage -> OppBackgroundBox: geb.navigator.NonEmptyNavigator
所以问题不在于 WebDriver 无法定位元素。
不同组件的版本出现在错误消息中。 Gecko 驱动版本为 0.24.0
目前我不知道这是 WebDriver、Geb 的问题还是我的一些配置/版本控制错误。
有没有人发现这个问题和解决方法?提前感谢您的帮助。
【问题讨论】:
-
欢迎来到 SO。完整的MCVE 会很有帮助。你可以编辑你的问题,顺便说一句。不幸的是,我无法运行您不连贯的代码 sn-ps。我建议你让这个问题可重现,然后你可以期待更好的答案。否则你要么根本得不到任何反馈,要么得到疯狂的猜测,这些都对你没有帮助。
标签: webdriver geckodriver geb selenium-firefoxdriver