protractor-net icon indicating copy to clipboard operation
protractor-net copied to clipboard

Testing angular app with recaptcha

Open igarifullin opened this issue 7 years ago • 4 comments

I have the angular app with recaptcha in login form. So I switch driver to recaptcha frame and click on checkbox. After this I switch back to the parent frame, find element on main form- and at this moment waitforangular waiting for recaptcha reset script ends. So I need to skip this, it is possible?

igarifullin avatar Oct 31 '16 16:10 igarifullin

Would it be possible for you to provide more details about what you mean by "waitforangular waiting for recaptcha reset script ends"? Could you provide us with code to reproduce the issue?

Here is some sample code checking a Recaptcha on the Angular Recaptcha demo website. As you might imagine, this version is too simplistic to fool the captcha library.

using (var ngDriver = new NgWebDriver(new ChromeDriver(), "[ng-app]"))
{
    ngDriver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(10));
    ngDriver.Url = "http://vividcortex.github.io/angular-recaptcha/";

    var frame = ngDriver.FindElement(By.TagName("iframe"));
    ngDriver.SwitchTo().Frame(frame);

    ngDriver.IgnoreSynchronization = true;
    var checkmark = ngDriver.FindElement(By.ClassName("recaptcha-checkbox-checkmark"));
    checkmark.Click();
    ngDriver.IgnoreSynchronization = false;

    ngDriver.SwitchTo().ParentFrame();
    ngDriver.FindElement(By.CssSelector("[vc-recaptcha]")).Click();
}

rendmath avatar Nov 04 '16 12:11 rendmath

Oh no, I'm using the test recaptcha key to always pass it. So this is my code - http://stackoverflow.com/questions/40346134/testing-angular-with-protractor-net-wrapper

After switching to parent frame (or previous window) the WaitForAngular script is waiting for nothing- and timeout fails. You should try to reduce my case. May be you'll solve this problem

igarifullin avatar Nov 04 '16 16:11 igarifullin

Does switching IgnoreSynchronization have any effect on your problem? Unless you provide us with a public facing page to reproduce the issue, it might prove difficult to solve.

rendmath avatar Nov 04 '16 21:11 rendmath

This fixed my issue on my project

clickOnNav() navigate to another page that contains Recaptcha.

Solution:

it('should navigate to recaptcha page', async () => {
    page.navigateTo();
    page.clickOnNav();
    browser.ignoreSynchronization = true; // Fix because of recaptcha
    browser.sleep(500);
    expect(page.getElementStepper()).toBeTruthy();
    browser.ignoreSynchronization = false;
});

gilsdav avatar Dec 05 '18 21:12 gilsdav