bbaia / protractor-net

The .NET port of Protractor, an E2E test framework for Angular apps
MIT License
115 stars 72 forks source link

Testing angular app with recaptcha #53

Open igarifullin opened 8 years ago

igarifullin commented 8 years ago

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?

rendmath commented 8 years ago

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();
}
igarifullin commented 8 years ago

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

rendmath commented 8 years ago

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.

gilsdav commented 5 years ago

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;
});