UnhandledPromiseRejectionWarning:未处理的承诺拒绝(拒绝ID:1):

时间:2018-03-02 15:04:04

标签: selenium-webdriver

我有这个代码用于selenium web驱动程序中的自动测试 我跑第一个,一切都好 但是使用新的表单控件

require('chromedriver');

const {Builder, By, Key, until} = require('selenium-webdriver');
var $ = require('selenium-query'); 

(async function example() {
  let driver = await new Builder().forBrowser('chrome').build();

  $driver = $(driver);
  try {
    // open page site local
    await driver.get('https://site.local.pt');

    await timeout(1000);
    $driver.find('.db-header-nav li:nth-child(3) .user-login').click();

    await timeout(3000);
    $driver.find('.register.individual').find('input[name="email"]').val("carlos+44@gmail.com");

    await timeout(500);
    $driver.find('#password-2').val("123");

    await timeout(1000);
    await driver.findElement(By.xpath("//a[contains(@class,'login-submit')]")).click();

  } finally {
  }
})();


function timeout(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

然后表单控件的html发出错误 我已经使用了sendkeys和同样的错误......

<div class="col-sm-6 col-sm-offset-3 box m-top20">

             <div class="col-sm-12 m-top20">
                <div class="form-content">
                    <form action="/entrar" method="POST" class="register individual" id="login-form-ajax" style="display: block;">
                        <div class="form-group">
                            <label>Email</label>
                            <input type="email" name="email" class="required form-control input-lg" id="email-3">
                        </div>
                        <div class="form-group">
                            <label for="password-2">Password</label>
                            <input type="password" name="password" class="required form-control input-lg" id="password-2">
                            <input type="text" style="display: none" value="0" name="taskerintention" id="taskerintention">
                            <input type="text" style="display: none" name="fingerprint" id="fingerprint">
                            <div class="loading-regist text-danger" id="ajax_register_indiv_response"></div>
                        </div>
                        <div class="form-group m-bottom0">
                            <label class="base-font medium">
                                <input name="remember" type="checkbox" checked=""> Lembrar-me                           </label>
                        </div>
                        <small><a id="rescue-pwd_btn" href="#/">Esqueceu-se da password?</a></small>
                        <div id="ajax_response"></div>
                        <div class="text-center m-top35 m-bottom15">
                            <button type="submit" id="loginbtn" class="btn btn-success btn-lg login-submit" data-loading-text="A processar...">Login</button>
                        </div>
                    </form>

                    <div class="clearfix">
    <div id="login-divider">
        <div class="text text-muted text-center">OU</div>
    </div>
</div>
<div class="clearfix">
    <div class="text-center m-top10 m-bottom15">
        <a class="facebook-login btn btn-facebook" href="/auth/facebooklogin"><span class="spr spr-fb-login"></span>Login pelo Facebook</a>
    </div>
</div>
                    <div class="row text-center m-top5 m-bottom10 p-bottom20">
                        Não é um utilizador <a href="/registo">Registe-se.</a>
                    </div>
                </div>
            </div>
        </div>

我正在尝试填写登录中的两个输入,但我在第一次尝试时收到错误

(node:4147) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:62427
(node:4147) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zerexit code.

任何人都可以帮助我在输入表单控件中输入键 它的内容很多

非常感谢 卡洛斯维埃拉

0 个答案:

没有答案