microsoft / EasyRepro

Automated UI testing API for Dynamics 365
MIT License
513 stars 285 forks source link

[HOW-TO] <Click automatically on the USE A VERIFICATION CODE> #1348

Closed RicardoJacobsen closed 1 year ago

RicardoJacobsen commented 1 year ago

Question

Why in the login process the automation does not work for USE A VERIFICATION CODE? (It should click automatically in use a verification code)

The automation is working fine till reaches this part image

I have to click manually on the part where it says use a verification code. After I click there the automation continues fine.

How to click on it automatically, so the test flows without human interaction?

Another thing that I would like to know is, how I prevent the web browser to be closed use the same the other test cases?

RicardoJacobsen commented 1 year ago

@aliyoussefi any suggestion?

Shakevg commented 1 year ago

RicardoJacobsen EasyRepro is not supported this for now. You should implement your own login method. Did you configure the account by instruction? Also, you should set added by instruction MFA option as default.

RicardoJacobsen commented 1 year ago

RicardoJacobsen EasyRepro is not supported this for now. You should implement your own login method. Did you configure the account by instruction? Also, you should set added by instruction MFA option as default.

Yes I did configured as in instruction. I did everything as in instructions to MFA Support. It's working beautifully till this part. Any workaround for this? Maybe alter the login method and add a selenium instruction to find the text " Use a verification code" and click on it?

RicardoJacobsen commented 1 year ago

I found a simple workaround for that. I simply created the method below:

  private static bool ClickUseVerificatioCode(IWebDriver driver)
        {
            var x = driver.FindElements(By.XPath("//*[contains(text(), 'Use a verification code')]"));
            x[1].Click();           
            return true;
        }

AND inserted after the method to input the password (WebClient.cs file).

Here is where I called the method;

   EnterPassword(driver, password);
                ThinkTime(2000);  
            }

            ClickUseVerificatioCode(driver); // This is where I placed the code

            int attempts = 0;
            bool entered;