Skip to content

Commit

Permalink
[BUG] Grid Sort not working in UCI | No more 1 click sort #942 (#966)
Browse files Browse the repository at this point in the history
* Added Selenium.WebDriver.ChromeDriver and removed Selenium.Chrome.WebDriver

* Updated UCI Grid Sort method to include a sort option button text

* updated missing element reference

* restore back to the original Selenium.Chrome.WebDriver

* Revert "restore back to the original Selenium.Chrome.WebDriver"

This reverts commit 31818b3.

Co-authored-by: Thathi Pammi <[email protected]>
  • Loading branch information
thathi and Thathi Pammi authored Sep 20, 2020
1 parent 0c6367f commit b2f1193
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public static class AppElements
{ "Grid_Rows" , "//div[contains(@role,'row')]"},
{ "Grid_ChartSelector" , "//span[contains(@id,'ChartSelector')]"},
{ "Grid_ChartViewList" , "//ul[contains(@role,'listbox')]"},
{ "Grid_SortColumn", "//div[@data-type='Grid']//div[@title='[COLNAME]']//div[@class='grid-header-text']"},
{ "Grid_SortColumn", "//div[@data-type='Grid']//div[@title='[COLNAME]']//div[contains(@class,'header')]"},
{ "Grid_CellContainer" ,"//div[@role='grid'][@data-id='grid-cell-container']"},
{ "Grid_ViewSelector" , "//span[contains(@id,'ViewSelector')]" },
{ "Grid_ViewContainer" , "//ul[contains(@id,'ViewSelector')]" },
Expand Down
5 changes: 3 additions & 2 deletions Microsoft.Dynamics365.UIAutomation.Api.UCI/Elements/Grid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ public List<GridItem> GetGridItems()
/// Sorts the grid by the column provided
/// </summary>
/// <param name="columnName">Label of the column name</param>
public void Sort(string columnName)
/// <param name="sortOptionButtonText">Sort option button text</param>
public void Sort(string columnName, string sortOptionButtonText)
{
_client.Sort(columnName);
_client.Sort(columnName, sortOptionButtonText);
}
}
}
5 changes: 4 additions & 1 deletion Microsoft.Dynamics365.UIAutomation.Api.UCI/WebClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,7 @@ public BrowserCommandResult<bool> SwitchChart(string chartName, int thinkTime =
});
}

public BrowserCommandResult<bool> Sort(string columnName, int thinkTime = Constants.DefaultThinkTime)
public BrowserCommandResult<bool> Sort(string columnName, string sortOptionButtonText, int thinkTime = Constants.DefaultThinkTime)
{
ThinkTime(thinkTime);

Expand All @@ -1789,7 +1789,10 @@ public BrowserCommandResult<bool> Sort(string columnName, int thinkTime = Consta
if (sortCol == null)
throw new InvalidOperationException($"Column: {columnName} Does not exist");
else
{
sortCol.Click(true);
driver.WaitUntilClickable(By.XPath($@"//button[@name='{sortOptionButtonText}']")).Click(true);
}

driver.WaitForTransaction();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void UCIGridSort()

xrmApp.Grid.SwitchView("Active Accounts");

xrmApp.Grid.Sort("Main Phone");
xrmApp.Grid.Sort("Main Phone", "Sort A to Z");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void UCITestGetActiveGridItems()

xrmApp.Grid.GetGridItems();

xrmApp.Grid.Sort("Account Name");
xrmApp.Grid.Sort("Account Name", "Sort Z to A");

xrmApp.ThinkTime(3000);
}
Expand Down

0 comments on commit b2f1193

Please sign in to comment.