【发布时间】:2014-05-16 15:51:12
【问题描述】:
好的,我有一个 Angular 应用程序,其中有指令和其他一些普通的 html 元素。 这个指令很有趣,因为它使用 RaphaelJs 来创建自定义图形。该指令还使用 require js 来加载依赖项(如 raphel.js)。一切正常:)
现在是困难的部分。我想写一些端到端的测试用例。我想选择指令创建的 svg 元素并检查一些属性值。
所以在浏览器 (Chrome) 控制台中,我键入 $('tspan'),我看到简单的 css 选择器返回了许多 tspans 元素。
样本时间跨度
<tspan dy="7" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Somevalue</tspan>
当我在 E2E 工作表中编写相同的查询时
var svgElement = $('tspan')[0];
console.log(svgElement);
它记录以下内容:
{ click: [Function],
sendKeys: [Function],
getTagName: [Function],
getCssValue: [Function],
getAttribute: [Function],
getText: [Function],
getSize: [Function],
getLocation: [Function],
isEnabled: [Function],
isSelected: [Function],
submit: [Function],
clear: [Function],
isDisplayed: [Function],
getOuterHtml: [Function],
getInnerHtml: [Function],
findElements: [Function],
isElementPresent: [Function],
evaluate: [Function],
'$$': [Function],
findElement: [Function],
'$': [Function],
find: [Function],
isPresent: [Function] }
当我尝试访问同一元素上的 getText 方法时,我得到了
var svgElement = $('tspan');
console.log(svgElement.getText());
C:\Users\abc\AppData\Roaming\npm\node_modules\protractor\node_modules\seleniu
m-webdriver\lib\webdriver\promise.js:1549
throw error;
^
Error while waiting for Protractor to sync with the page: {}
无法理解根本原因。有人可以帮忙吗?
【问题讨论】:
-
尝试添加“browser.ignoreSynchronization = true;” (或“ptor.ignoreSynchronization = true;”)在运行您的第一个测试之前。
标签: angularjs protractor