ara*_*hak 4 java iframe selenium xpath selenium-rc
我需要输入数据到iframe.我提到了
但selenium.selectFrame(<xpath>)返回:Element not found error并没有为此定义css iframe.
使用firebug:
<iframe frameborder="0" allowtransparency="true" tabindex="0" src="" title="Rich text editor, templateWizardCKEditor1, press ALT 0 for help." style="width: 100%; height: 100%;"/>
Run Code Online (Sandbox Code Playgroud)
什么可以解决这个问题?
小智 6
我找到了相同的解决方案......
driver.switchTo().frame("ext-gen298");
WebElement editable = driver.switchTo().activeElement();
editable.sendKeys("Your text here");
driver.switchTo().defaultContent();
Run Code Online (Sandbox Code Playgroud)
参考:http://code.google.com/p/seleniumwikiFrequentlyAskedQuestions#Q : _How_do_I_type_into_a_contentEditable_iframe?
那只是意味着你使用了一些错误的 xpath。
selenium.selectFrame("xpath=//iframe[contains(@title,'Rich text editor')]");
Run Code Online (Sandbox Code Playgroud)
这应该有效。它根据 xpath 表达式选择 iframe,该表达式查找标题属性包含“富文本编辑器”的 iframe。
有关更多 xpath,请参阅w3.org 上的 XPath v1.0和w3.org 上的 XPath v2.0 - 仅适用于某些浏览器。
顺便说一句,iframe 也可以通过 css 选择器来选择,即使它没有分配 css。选择器可以根据其在树层次结构中的位置及其属性来选择任何元素 - 类似于 XPath。要了解 css 选择器,请再次尝试 w3或维基百科
| 归档时间: |
|
| 查看次数: |
9554 次 |
| 最近记录: |