首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在量角器cucumber中,getAttribute(值)返回Object (browser_,then,...)而不是返回数据

在量角器cucumber中,getAttribute(值)返回Object (browser_,then,...)而不是返回数据
EN

Stack Overflow用户
提问于 2019-01-18 23:09:22
回答 1查看 264关注 0票数 0

尝试断言在以下网页值(‘getAttribute’)中输入的日期时,返回"Object (browser_,then,...)“而不是价值。https://material.angular.io/components/datepicker/examples

下面是给出错误的代码片段

代码语言:javascript
复制
expect(element(by.xpath('//input[@id="mat-input-2"]')).getAttribute('value')).to.eventually.equal(element(by.xpath('//input[@id="mat-input-2"]')).getAttribute('value')).and.notify(callback);

为此,我得到以下错误对象:期望'1/6/2019‘等于{AssertionError (browser_,then,...) }

代码语言:javascript
复制
     var date=element(by.xpath('//input[@id="mat-input-2"]')).getAttribute('value').getText();
  console.log(date);

上面代码的console.log返回的内容如下所示。

代码语言:javascript
复制
ElementFinder {
browser_:
  ProtractorBrowser {
 controlFlow: [Function],
 schedule: [Function],
 setFileDetector: [Function],
 getExecutor: [Function],
 getSession: [Function],
 getCapabilities: [Function],
 quit: [Function],
 actions: [Function],
 touchActions: [Function],
 executeScript: [Function],
 executeAsyncScript: [Function],
 call: [Function],
 wait: [Function],
 sleep: [Function],
 getWindowHandle: [Function],
 getAllWindowHandles: [Function],
 getPageSource: [Function],
 close: [Function],
 getCurrentUrl: [Function],
 getTitle: [Function],
 findElementInternal_: [Function],
 findElementsInternal_: [Function],
 takeScreenshot: [Function],
 manage: [Function],
 switchTo: [Function],
 driver:
  Driver {
    flow_: [ControlFlow],
    session_: [ManagedPromise],
    executor_: [Executor],
    fileDetector_: null,
    onQuit_: undefined,
    getNetworkConnection: [Function],
    setNetworkConnection: [Function],
    toggleAirplaneMode: [Function],
    toggleWiFi: [Function],

请提供一些解决方案

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-18 23:20:40

试一试:

代码语言:javascript
复制
const elementOne = element(by.xpath('//input[@id="mat-input-2"]');
const elementTwo = element(by.xpath('//input[@id="mat-input-2"]');

return elementOne.getAttribute('value').then((elementOneValue) => {
    return expect(elementTwo.getAttribute('value')).to.eventually.equal(elementOneValue).and.notify(callback);
});

顺便说一句。这两个元素有相同的选择器-它们必须相等。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54256670

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档