1. <legend id='4FpRd'><style id='4FpRd'><dir id='4FpRd'><q id='4FpRd'></q></dir></style></legend>

      <tfoot id='4FpRd'></tfoot>
      <i id='4FpRd'><tr id='4FpRd'><dt id='4FpRd'><q id='4FpRd'><span id='4FpRd'><b id='4FpRd'><form id='4FpRd'><ins id='4FpRd'></ins><ul id='4FpRd'></ul><sub id='4FpRd'></sub></form><legend id='4FpRd'></legend><bdo id='4FpRd'><pre id='4FpRd'><center id='4FpRd'></center></pre></bdo></b><th id='4FpRd'></th></span></q></dt></tr></i><div id='4FpRd'><tfoot id='4FpRd'></tfoot><dl id='4FpRd'><fieldset id='4FpRd'></fieldset></dl></div>

      <small id='4FpRd'></small><noframes id='4FpRd'>

        <bdo id='4FpRd'></bdo><ul id='4FpRd'></ul>

      Angularjs,使用 angular-recaptcha 进行 e2e 测试

      时间:2023-10-12
    2. <legend id='dS6Iy'><style id='dS6Iy'><dir id='dS6Iy'><q id='dS6Iy'></q></dir></style></legend>

      <small id='dS6Iy'></small><noframes id='dS6Iy'>

      <i id='dS6Iy'><tr id='dS6Iy'><dt id='dS6Iy'><q id='dS6Iy'><span id='dS6Iy'><b id='dS6Iy'><form id='dS6Iy'><ins id='dS6Iy'></ins><ul id='dS6Iy'></ul><sub id='dS6Iy'></sub></form><legend id='dS6Iy'></legend><bdo id='dS6Iy'><pre id='dS6Iy'><center id='dS6Iy'></center></pre></bdo></b><th id='dS6Iy'></th></span></q></dt></tr></i><div id='dS6Iy'><tfoot id='dS6Iy'></tfoot><dl id='dS6Iy'><fieldset id='dS6Iy'></fieldset></dl></div>

              • <bdo id='dS6Iy'></bdo><ul id='dS6Iy'></ul>
                  <tbody id='dS6Iy'></tbody>
                <tfoot id='dS6Iy'></tfoot>
              • 本文介绍了Angularjs,使用 angular-recaptcha 进行 e2e 测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我实际上是在尝试对我的简单应用程序进行 e2e 测试,但在处理 angular-recaptcha 时遇到了一些麻烦(https://github.com/VividCortex/angular-recaptcha).

                I'm actually trying to e2e test my simple application and I m having some troubles dealing with angular-recaptcha (https://github.com/VividCortex/angular-recaptcha).

                这是我的测试:

                  it('should redirect on another page', function() {
                
                    browser.get('http://127.0.0.1:3000/#/');
                    var userName = element(by.model('auth.loginInfos.username'));
                    userName.sendKeys('consumer1@eco.com');
                
                    var password = element(by.model('auth.loginInfos.password'));
                    password.sendKeys('consumer1');
                
                
                
                    var recapt = element(by.id('recaptcha'));
                    recapt.sendKeys();/* How can I put the recaptcha value to true ? */
                
                    var btn = element(by.className('btn'));
                    btn.click();
                    /**
                     * Assertions etc...
                     */
                
                  });
                

                所以,您可以看到我正在尝试填写 recaptcha 值,但我不知道如何继续.

                So, you can see that I m trying to fill the recaptcha value and I don't know how to proceed.

                你能帮帮我吗?

                注意:我正在使用量角器

                感谢您的帮助

                推荐答案

                验证码加载在一个iframe中,需要先切换到它再尝试检查:

                The captcha is loaded in an iframe, you need to switch to it before trying to check:

                browser.switchTo().frame(0);
                

                其中 0 是帧索引.您可以使用框架名称、ID 或以前找到的框架元素.

                where 0 is a frame index. You can use a frame name, id or a previously found frame element.

                使用 recaptcha 演示页面的示例测试:

                Sample test that uses the recaptcha demo page:

                "use strict";
                
                describe("Recaptcha", function () {
                    beforeEach(function () {
                        browser.ignoreSynchronization = true;
                        browser.get("http://vividcortex.github.io/angular-recaptcha/");
                    });
                
                    it("should click the captcha", function () {
                        browser.switchTo().frame(0).then(function () {
                            var checkbox = $(".recaptcha-checkbox-checkmark");
                
                            // first hover the checkbox
                            browser.actions().mouseMove(checkbox).perform();
                
                            // hardcoded delay
                            browser.sleep(500);
                
                            // okat, now click - TODO: may be we should click with browser.actions().click() and provide the x, y coordinates for where to click
                            checkbox.click();
                        });
                
                        // expectations
                    });
                });
                

                请注意,在我的情况下,单击后,它会要求选择某些图像,这些图像完全可以完成不让我的 selenium 自动化机器人通过测试的工作.如果你想真正通过验证码,根据 新的 Google reCAPTCHA 是如何工作的? 页面以及有关此验证码如何工作的已知信息,我会尝试以下操作:

                Note that in my case, after the click, it asks to select certain images that would exactly do the job of not letting my selenium automation bot pass the test. If you want to actually pass the captcha, according to the How does new Google reCAPTCHA work? page and the known information about how this captcha works, I would try the following things:

                • 使用您以前使用过的预加载配置文件打开浏览器(至少有浏览历史记录)
                • 在启动测试的浏览器中登录谷歌帐户
                • 不要像普通人那样通过 click() 点击复选框并使用偏移量点击它
                • 玩弄浏览器操作之间的延迟
                • open the browser with a pre-loaded profile that you've used before (that has the browsing history, at least)
                • be logged into google account in the browser fired up for testing
                • don't click the checkbox via click() and click it with an offset as a regular human would do
                • play around with a delays between browser actions

                另一点是,您无需对验证码的工作方式进行 e2e 测试 - 它超出了应用程序端到端测试的范围.找到一种方法来为测试用户禁用/关闭验证码,或者为您将针对其运行测试的特定构建.

                Another point is that, you don't need to e2e test how the captcha works - it is out of scope of the end-to-end testing of your application. Find a way to disable/turn the captcha off for the testing users, or for a specific build that you will be running tests against.

                这篇关于Angularjs,使用 angular-recaptcha 进行 e2e 测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:使用 each() 方法时的量角器过时元素引用 下一篇:量角器未知错误,从 DOM 中删除属性

                相关文章

                最新文章

              • <legend id='fmfER'><style id='fmfER'><dir id='fmfER'><q id='fmfER'></q></dir></style></legend>

                  <tfoot id='fmfER'></tfoot>

                    • <bdo id='fmfER'></bdo><ul id='fmfER'></ul>

                    <small id='fmfER'></small><noframes id='fmfER'>

                    <i id='fmfER'><tr id='fmfER'><dt id='fmfER'><q id='fmfER'><span id='fmfER'><b id='fmfER'><form id='fmfER'><ins id='fmfER'></ins><ul id='fmfER'></ul><sub id='fmfER'></sub></form><legend id='fmfER'></legend><bdo id='fmfER'><pre id='fmfER'><center id='fmfER'></center></pre></bdo></b><th id='fmfER'></th></span></q></dt></tr></i><div id='fmfER'><tfoot id='fmfER'></tfoot><dl id='fmfER'><fieldset id='fmfER'></fieldset></dl></div>