microsoft / EasyRepro

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

regarding Location dialogue in CRM app #1382

Open chandramohand opened 12 months ago

chandramohand commented 12 months ago

My CRM form deals with google maps, when I open the CRM application it opens the location dialogue, how to accept and close that dialogue. Screenshot attached. testscreenshot

Could anyone please help regarding this.

Thanks in Advance, Chandra.

Shakevg commented 12 months ago

chandramohand This option is not supported now by Framework, but you can try extend with the custom solution https://stackoverflow.com/questions/48007699/how-to-allow-or-deny-notification-geo-location-microphone-camera-pop-up

One more option implement custom login and use WinAppDriver to handle dialog

chandramohand commented 12 months ago

Thanks @Shakevg, let me try and update you if any issues.

chandramohand commented 12 months ago

Hi @Shakevg, I am unable to pass this extra option to the same browser, where I am using the following browser options. If i declare [ ChromeOptions opt;
opt.AddArgument("--disable-geolocation"); ] I need to pass this new webdriver, where its going to apply for new broswer. How can I pass this location disable option, to the existing client only? public static BrowserOptions Options = new BrowserOptions { BrowserType = (BrowserType)Enum.Parse(typeof(BrowserType), Type), PrivateMode = true, FireEvents = false, Headless = false, UserAgent = false, DefaultThinkTime = 2000, UCITestMode = true, CookieСontrolsMode = 0,

    };
Shakevg commented 12 months ago

chandramohand 2 options:

  1. Include library source code to your project and modify the source with a new option
  2. Implement new option in Framework and commit to GitHub
AngelRodriguez8008 commented 11 months ago

@chandramohand I didn't test it for this argument, but, if you use Chrome, you can use the ExtraChromeArguments Option as follows.

            //1. Global in [ClassInitialize] or [AssemblyInitialize] methods
            TestSettings.SharedOptions.ExtraChromeArguments = new[] { "--disable-geolocation" };

            // 2. just for one test
            var options = TestSettings.Options;
            options.ExtraChromeArguments = new[] { "--disable-geolocation" };
            var client = new WebClient(options);
            using (var xrmApp = new XrmApp(client))
            {  
            ...
chandramohand commented 11 months ago

Thanks @AngelRodriguez8008, @sharkdevs I am trying to use the second options in my settings where not allowing the ExtraChromeArguments options. Running thise in incognito mode. protected XrmApp XrmApp { get { if (_xrmApp == null) { var options = TestSettings.Options; options.ExtraChromeArguments = new[] { "--disable-geolocation" }; var client = new WebClient(options); _xrmApp = new XrmApp(Client); } return _xrmApp; } } I am getting the following error.

Severity Code Description Project File Line Suppression State Error CS1061 'BrowserOptions' does not contain a definition for 'ExtraChromeArguments' and no accessible extension method 'ExtraChromeArguments' accepting a first argument of type 'BrowserOptions' could be found (are you missing a using directive or an assembly reference?) Ntdt.Tests C:\Users\dast0002\source\repos\test\Ntdt.Tests\Ntdt.Tests.Tests\XrmBinding.cs 41 Active

Option 2: Tried as the following by adding the argument, but still the dialog opens. Trying to assigning the folloiwng options to client. var options = TestSettings.Options; options.ToChrome().AddArgument("--disable-geolocation");

Could you please help me.

Thanks, Chandra.

AngelRodriguez8008 commented 11 months ago

@chandramohand Sorry, this logic was implemented just in my fork. I add a Pull Request that support my sample code. You can download & compile it or wait until the PR get approved. I also added this particular configuration to a Sample Test Case options.ExtraChromeArguments = new[] { "--disable-geolocation" };

With the new code, you can also change the SharedOptions initialization in your project in order to enable this configuration for all your tests. Just add this line: ExtraChromeArguments = new[] { "--disable-geolocation" }; at the end of the follow BrowserOptions constructor call. TestSettings.SharedOptions, after line 51

The Option 2 as you implemented it will not work. You are getting your own copy of the Options, but this will not be used for the driver later on.

chandramohand commented 11 months ago

Hi @AngelRodriguez8008, Thanks for quick response. Few things just want to check, whether this supports the old chrome browser 101 version? when I ran the lab test its expecting 113 version. Please confirm.

2nd hope this will work fine in private mode.

Thanks and Regards, Chandra.

AngelRodriguez8008 commented 11 months ago

@chandramohand you should up- or downgrade the Selenium.WebDriver.ChromeDriver to the desired version. private mode should not be a problem

chandramohand commented 11 months ago

Hi @AngelRodriguez8008, Applied the changes to my portal but its not working, where the location dialogue opens after login which is required to load the map. I tried both enable and disable, but didnt work. Thanks, Chandra.

chandramohand commented 11 months ago

Hi @AngelRodriguez8008, Hope you are doing good. Any update regarding this?

Thanks, Chandra

AngelRodriguez8008 commented 11 months ago

Hi @chandramohand

The Pull Request is waiting to be reviewed. How I said, you can try to get the new code/branch & compile it for yourself. In other case, you should wait for some of the repository owners.

chandramohand commented 11 months ago

Hi @chandramohand

The Pull Request is waiting to be reviewed. How I said, you can try to get the new code/branch & compile it for yourself. In other case, you should wait for some of the repository owners.

Thanks @AngelRodriguez8008, I got the code for Browseroptions and TestSetting and tried on my CRM app, please refer to the following code. Still after login the dialogue still remains. Here in the CRM app I need to allow the location, where it pulls only those location points. I want to check initally whethere the dialog get closes, later I will try making enable location. [TestCategory("Labs - TestsBase")] [TestMethod] public void NotUsing_TheBaseClass() { var options = TestSettings.Options; options.PrivateMode = true; options.TimeFactor = 1.5f; options.ExtraChromeArguments = new[] { "--disable-geolocation" };

        options.UCIPerformanceMode = false; // <= you can also change other settings here, for this tests only

        var client = new WebClient(options);
        using (var xrmApp = new XrmApp(client))
        {
            xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecretKey); // Here I am passing my app details

            Assert.IsNotNull("Replace this line with your test code");

        }  // Note: that here get the Browser closed, xrmApp get disposed
    }

Thanks and Regards, Chandra.

chandramohand commented 10 months ago

Hi @chandramohand The Pull Request is waiting to be reviewed. How I said, you can try to get the new code/branch & compile it for yourself. In other case, you should wait for some of the repository owners.

Thanks @AngelRodriguez8008, I got the code for Browseroptions and TestSetting and tried on my CRM app, please refer to the following code. Still after login the dialogue still remains. Here in the CRM app I need to allow the location, where it pulls only those location points. I want to check initally whethere the dialog get closes, later I will try making enable location. [TestCategory("Labs - TestsBase")] [TestMethod] public void NotUsing_TheBaseClass() { var options = TestSettings.Options; options.PrivateMode = true; options.TimeFactor = 1.5f; options.ExtraChromeArguments = new[] { "--disable-geolocation" };

        options.UCIPerformanceMode = false; // <= you can also change other settings here, for this tests only

        var client = new WebClient(options);
        using (var xrmApp = new XrmApp(client))
        {
            xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecretKey); // Here I am passing my app details

            Assert.IsNotNull("Replace this line with your test code");

        }  // Note: that here get the Browser closed, xrmApp get disposed
    }

Thanks and Regards, Chandra.

Hi @AngelRodriguez8008, I tried with the sample but didnt work, just want to follow up, as I see the pull request is in still Review state, Any update regarding this. Thanks, Chandra.

chandramohand commented 7 months ago

Hi @AngelRodriguez8008, any update of this PR? Thanks, Chandra.