【发布时间】:2015-03-02 14:01:09
【问题描述】:
无法理解为什么它返回一个对象而不是文本值,一些测试代码:
describe('columns swap', function () {
describe('location column ', function () {
it('should swap right', function () {
browser.sleep(10000);
var fColumn = element(by.xpath('(//*[@class="k-link"])[2]')).getText();
console.log(fColumn);
控制台输出:
> columns swap
> location column { ptor_: { controlFlow: [Function],
> schedule: [Function],
> getSession: [Function],
> getCapabilities: [Function],
> quit: [Function],
> actions: [Function],
> executeScript: [Function],
> executeAsyncScript: [Function],
> call: [Function],
> wait: [Function],
> sleep: [Function],
> getWindowHandle: [Function],
> getAllWindowHandles: [Function],
> getPageSource: [Function],
> close: [Function],
> getCurrentUrl: [Function], ...
如果我将此部分与 expect() 一起使用:
expect(columnSorting.acpColumn.getText()).to.eventually.equal(fColumn);
我明白了:
1) columns swap location column should swap right:
AssertionError: expected 'Location' to equal { Object (ptor_, parentElement
ArrayFinder, ...) }
所以出于某种原因,我可以从期望中获取文本并且它是正确的 - '位置'
我做错了什么?
【问题讨论】:
-
你也可以使用async / await来管理promise
标签: javascript selenium-webdriver promise protractor end-to-end