microsoft / EasyRepro

Automated UI testing API for Dynamics 365
MIT License
514 stars 286 forks source link

Online Wave2 : xrmApp.Grid.OpenRecord(0) : I can't select a row grid after search action #1216

Open jaziriferes1 opened 2 years ago

jaziriferes1 commented 2 years ago

Bug Report

Issues should only be created for items related to covered functionality.

Not covered functionality, feature requests, and questions should use the Feature Request or Question templates.

EasyRepro Version

UCI or Classic Web

Online or On Premise

Browser

Describe the bug

Special formatting / display

Code to reproduce

Expected behavior

Screenshots

Additional context

ewingjm commented 2 years ago

Should be fixed in develop-2021ReleaseWave2 branch. See #1206. There hasn't been a wave 2 NuGet version released yet.

jkanschik commented 2 years ago

I also experience an issue with Grid.OpenRecord(0) in the latest version of branch develop-2021ReleaseWave2. It seems that the linked ticket doesn't fix the issue completely. Error message is Unable to locate element: {"method":"xpath","selector":"//div[@ref='eViewport']"}

The test Microsoft.Dynamics365.UIAutomation.Sample.UCI.Grid.UCIGridOpenRecord() fails when OpenRecord(0) is called:

    BrowserAutomation Information: 10004 : Command Retry: Open Grid Record - OpenQA.Selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@ref='eViewport']"}
    (Session info: chrome=95.0.4638.69) - Retry 5/5 initiated
    BrowserAutomation Information: 10003 : Command Failure: Open Grid Record - 5 attempts - total execution time 20102,5376ms - Return Result: OpenQA.Selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@ref='eViewport']"}
  (Session info: chrome=95.0.4638.69)
   bei OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
   bei OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   bei OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)
   bei OpenQA.Selenium.Remote.RemoteWebDriver.FindElementByXPath(String xpath)
   bei OpenQA.Selenium.By.<>c__DisplayClass19_0.<XPath>b__0(ISearchContext context)
   bei OpenQA.Selenium.By.FindElement(ISearchContext context)
   bei OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by)
   bei Microsoft.Dynamics365.UIAutomation.Api.UCI.WebClient.<>c__DisplayClass77_0.<OpenRecord>b__0(IWebDriver driver) in C:\Users\...\crm\EasyRepro\Microsoft.Dynamics365.UIAutomation.Api.UCI\WebClient.cs:Zeile 1544.
   bei Microsoft.Dynamics365.UIAutomation.Browser.DelegateBrowserCommand`1.ExecuteCommand(IWebDriver driver, Object[] params) in C:\Users\...\crm\EasyRepro\Microsoft.Dynamics365.UIAutomation.Browser\DelegateBrowserCommand.cs:Zeile 28.
   bei Microsoft.Dynamics365.UIAutomation.Browser.BrowserCommand`1.Execute[T1,T2,T3,T4,T5,T6,T7,T8,T9](IWebDriver driver, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7, T8 p8, T9 p9) in C:\Users\...\crm\EasyRepro\Microsoft.Dynamics365.UIAutomation.Browser\BrowserCommand.cs:Zeile 103.
aliyoussefi commented 2 years ago

Hi @jkanschik ,

Let me take a look at this one shortly and confirm if I can reproduce on my end.

Thanks! Ali

aliyoussefi commented 2 years ago

Hi @jkanschik ,

Let me take a look at this one shortly and confirm if I can reproduce on my end.

Thanks! Ali

I am unable to reproduce this in two environments I have for testing. Can you confirm the build version of the environment you're using?

ewingjm commented 2 years ago

I'm sure we're also using this method successfully - @jkanschik is it a standard read-only grid or is it an editable grid?

jkanschik commented 2 years ago

Actually, I just realized that for Opportunities and also some other entities, OpenRecord() works perfectly. At least for my current environment, the UI for Accounts and Opportunities are actually different. Completely different HTML / CSS.

Do you have the same grids for Sales Hub => Account and Sales Hub => Opportunities?

jkanschik commented 2 years ago

I'm on 2021 Release Wave 2, Database version 9.2.21102.00131

In Sales Hub, these are the two mentioned lists; as you can see, the UI is different:

List of opportunities: image

List of accounts: image

ewingjm commented 2 years ago

@jkanschik haven't checked but the accounts grid there looks like an editable grid. The 'Group By' is present on editable grids, at least, and I don't believe they got updated in wave 2. The logic for opening records was probably quite similar for editable grids and read-only grids before so it may have actually worked in the past despite the grids different and there not being any obvious code path for it.

BigIan1969 commented 1 year ago

Am seeing this issue in version 9.2.22083.00150 is there a work around

int row = 0; xrmApp.Grid.OpenRecord(row);

Message: input cannot be null (Parameter 'input')

Source: Microsoft.Dynamics365.UIAutomation.Browser

Stack Trace: at Microsoft.Dynamics365.UIAutomation.Browser.BrowserCommand1.Execute[T1,T2,T3,T4,T5,T6,T7,T8,T9](IWebDriver driver, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7, T8 p8, T9 p9) at Microsoft.Dynamics365.UIAutomation.Browser.BrowserCommand1.Execute(IWebDriver driver) at Microsoft.Dynamics365.UIAutomation.Browser.BrowserPage.Execute[TResult](BrowserCommandOptions options, Func2 delegate) at Microsoft.Dynamics365.UIAutomation.Api.UCI.WebClient.OpenRecord(Int32 index, Int32 thinkTime, Boolean checkRecord) at Microsoft.Dynamics365.UIAutomation.Api.UCI.Grid.OpenRecord(Int32 index) at GenericFramework.StepD365.GridOpenRecord(Target TargetElement, String data) in C:\Users\sesiho\Source\Repos\BANNER-Test\SLP-SMOKE\GenericFramework\StepD365.cs:line 70 at GenericFramework.Testcase.Steps(String action, String target, String data, String[] rowdata) in C:\Users\sesiho\Source\Repos\BANNER-Test\SLP-SMOKE\GenericFramework\Testcase.cs:line 611 at GenericFramework.Testcase.Execute(String tc, IDictionary2 _vars, IDictionary2 _datalookup, String[] _rowdata, IDictionary2 _reports, List`1 _dataoutput) in C:\Users\sesiho\Source\Repos\BANNER-Test\SLP-SMOKE\GenericFramework\Testcase.cs:line 511

tipsey commented 1 year ago

I am also getting issue on xrmApp.Grid.OpenRecord(0); 2022 release wave 2 enabled Server version: 9.2.22103.00172

OpenQA.Selenium.NoSuchElementException: No records were found in the grid.

Stack Trace:  BrowserCommand1.Execute[T1,T2,T3,T4,T5,T6,T7,T8,T9](IWebDriver driver, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7, T8 p8, T9 p9) line 138 BrowserCommand1.Execute(IWebDriver driver) line 35 BrowserPage.Execute[TResult](BrowserCommandOptions options, Func`2 delegate) line 182 WebClient.OpenRecord(Int32 index, Int32 thinkTime, Boolean checkRecord) line 1535 Grid.OpenRecord(Int32 index) line 32

I have an ugly hack:

//xrmApp.Grid.OpenRecord(0);

            xrmApp.ThinkTime(3000);
            var x = client.Browser.Driver.FindElements(By.XPath("//*[contains(@class,'ms-Check-check') and contains(text(),'')]"));
            x[0].Click();  //Selects all radio row selectors
            x[1].Click();

            x[0].Click();
            x[0].Click();
            xrmApp.ThinkTime(5000);

            x[1].Click(); //Selects first row by clicking on radio button on that row
            xrmApp.CommandBar.ClickCommand("Edit");

The EasyRepro-wave2-fix-patch-1.zip contains a fix but there were too many other things broken in that patch.

Anyone else getting success / workarounds?

tipsey commented 1 year ago

I think I found a solution by implementing a fix from ReleaseWave2 patch 1. It worked for me

https://github.com/microsoft/EasyRepro/pull/1186/commits/27ee5a91936b8d2fd75d6b342a904f31ab40ad42

WebClient.cs

internal BrowserCommandResult OpenRecord(int index, int thinkTime = Constants.DefaultThinkTime, bool checkRecord = false) { ThinkTime(thinkTime); return Execute(GetOptions("Open Grid Record"), driver => { var xpathToGrid = By.XPath(AppElements.Xpath[AppReference.Grid.Container]); IWebElement control = driver.WaitUntilAvailable(xpathToGrid);

            Func<Actions, Actions> action;
            if (checkRecord)
                action = e => e.Click();
            else
                action = e => e.DoubleClick();

            var xpathToCell = By.XPath($".//div[@role='rowgroup']/div[@row-index={index}]");
            control.WaitUntilClickable(xpathToCell,
                cell =>
                {
                    var emptyDiv = cell.FindElement(By.TagName("div"));
                    driver.Perform(action, cell, cell.LeftTo(emptyDiv));
                },
                $"An error occur trying to open the record at position {index}"
                );

            driver.WaitForTransaction();
            return true;
        });
    }

///

/// Returns the Header Title of the entity /// /// Header Title of the Entity internal BrowserCommandResult GetHeaderTitle(int thinkTime = Constants.DefaultThinkTime) { return this.Execute(GetOptions($"Get Header Title"), driver => { // Wait for form selector visible var headerTitle = driver.WaitUntilVisible(By.XPath(AppElements.Xpath[AppReference.Entity.HeaderTitle]), new TimeSpan(0, 0, 5));

            var headerTitleName = headerTitle?.GetAttribute("title");

            if (string.IsNullOrEmpty(headerTitleName))
            {
                throw new NotFoundException("Unable to retrieve Header Title for this entity");
            }

            return headerTitleName;
        });
    }

Microsoft.Dynamics365.UIAutomation.Api.UCI/DTO/AppElementReference.cs

//Grid { "Grid_Container" , "//div[@role=\"grid\"]"}, { "Grid_QuickFind" , "//*[contains(@id, \'quickFind_text\')]"}, { "Grid_NextPage" , "//button[contains(@data-id,'moveToNextPage')]"},

DotaABhash commented 3 months ago

Hello, i have this issue while delete a Lead it gives out an error indicating it cannot find the element. Is it xpath issue ? i tried using the xpath inspecting the browser but did not find a match, so i tried my own xpath and still got the same error. Can you plz help me out on this.... thankyou [my xpath: //div[@Class='ms-StackItem truncatableText-409']] Message:  Test method Microsoft.Dynamics365.UIAutomation.Sample.UCI.UpdateLeadUCI.UCITestUpdateActiveLead threw exception: OpenQA.Selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@tabindex='0' and https://github.com/ROLE='checkbox']"} (Session info: MicrosoftEdge=123.0.2420.53)

Stack Trace:  BrowserCommand1.Execute[T1,T2,T3,T4,T5,T6,T7,T8,T9](IWebDriver driver, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7, T8 p8, T9 p9) line 140 BrowserCommand1.Execute(IWebDriver driver) line 35 BrowserPage.Execute[TResult](BrowserCommandOptions options, Func`2 delegate) line 182 WebClient.OpenRecord(Int32 index, Int32 thinkTime, Boolean checkRecord) line 1535 Grid.OpenRecord(Int32 index) line 32 UpdateLeadUCI.UCITestUpdateActiveLead() line 35 image