使用nightwatch-api的步骤定义中client.elements无法正常工作 [英] client.elements is not working from a step definition using nightwatch-api

查看:72
本文介绍了使用nightwatch-api的步骤定义中client.elements无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对BDD进行夜视和黄瓜集成.我无法在步骤函数中访问client.elements函数.

I'm trying to do nightwatch and cucumber integration for BDD. I'm unable to access client.elements function in a step function.

  const { client } = require('nightwatch-api');
  const { Given, Then, When } = require('cucumber');
  const homePage = client.page.homepage();


    Then(/^click "([^"]*)" service from list$/, async(service)  => {
        let result = await client.url('http://localhost:8080/').elements('css selector', 'div.flex.mt-4.v-card.v-sheet.theme--light > div > div > table > tbody > tr');
        console.log(" col length is " + "<->" + result.value.length);
        return homePage; 

      });

感谢您的帮助.谢谢!

推荐答案

我尝试复制此内容,以下内容对我有用.

I tried to replicate this and below is working for me.

await client.url('https://www.phptravels.net/home').moveToElement('css selector', '.product-grid-item', 0, 0).elements('css selector', '.product-grid-item', (res) => {
    console.log("%%%%%%% col length is " + "<-> " + res.value.length);
  });

我不确定是否可以将元素api返回的响应存储在变量中.如果找到解决方法,我将更新此答案.

I am not sure if we can store the response returned from elements api in a variable. I will update this answer if I find a way to do that.

这篇关于使用nightwatch-api的步骤定义中client.elements无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆