Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fixes #707

Merged
merged 2 commits into from
Jan 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public static class AppElements
{ "Entity_LookupFieldResultList", "//*[contains(@data-id, '[NAME].fieldControl-LookupResultsDropdown_[NAME]_tab')]" },
{ "Entity_LookupFieldResultListItem", "//*[contains(@data-id, '[NAME].fieldControl-LookupResultsDropdown_[NAME]_resultsContainer')]" },
{ "Entity_LookupFieldHoverExistingValue", "//*[contains(@data-id, '[NAME].fieldControl-LookupResultsDropdown_[NAME]_SelectedRecordList')]" },
{ "Entity_TextFieldLookupFieldContainer", "//div[@role='tabpanel']/parent::*//*[contains(@data-id, '[NAME].fieldControl-Lookup_[NAME]')]" },
{ "Entity_TextFieldLookupFieldContainer", "//div[@data-id='[NAME].fieldControl-Lookup_[NAME]']" },
{ "Entity_RecordSetNavigatorOpen", "//button[contains(@data-lp-id, 'recordset-navigator')]" },
{ "Entity_RecordSetNavigator", "//button[contains(@data-lp-id, 'recordset-navigator')]" },
{ "Entity_RecordSetNavList", "//ul[contains(@data-id, 'recordSetNaveList')]" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,15 @@ public static IWebElement WaitUntilAvailable(this IWebDriver driver, By by, Time

try
{
returnElement = wait.Until(d => d.FindElement(by));

var foundElements = wait.Until(d => d.FindElements(by));
Copy link
Contributor

@AngelRodriguez8008 AngelRodriguez8008 Jan 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[UPDATED] There is a problem hier, if you call FindElements if the element is not already loaded, you will get an Empty Collection but not NULL. That's means you will not really "wait", see the implementation of wait.Until:
image

For me fail at Login Dialog by "Enter Email"
To get the desired Effect you need to do something like that:

Func<IWebDriver, IWebElement> conditions = d =>
{
    ReadOnlyCollection<IWebElement> elements = d.FindElements(by);
    int? count = elements?.Count;
    if (count == null || count == 0)
        return null;

    var result = count > 1
        ? elements.FirstOrDefault(x => x?.Displayed == true)
        : elements.First(x => x != null);
    
    return result;
};
returnElement  = wait.Until(conditions);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi AngelRodriguez8008,
Sorry I haven't been checking github and i've moved on from doing automated testing for D365.
Your previous post showed great explanation to the root of the issue. Can you please refactor the codes and apply the fix for it because you can test the login dialog issue. I did have some random UCI login issue few weeks ago but it was inconsistent (1 issue out of 5 runs sort of thing) so I didn't look into it.
If you want me to do it, i'll need to spend sometime setting up D365 classic web app and test the codes. Let me know what you wanna do. Cheers

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @KhoaAN, I already fixed it in two PRs (#735, #747)

if (foundElements != null && foundElements.Count > 1)
{
returnElement = foundElements.FirstOrDefault(x => x.Displayed == true);
}
else
{
returnElement = foundElements.FirstOrDefault();
}
success = true;
}
catch (NoSuchElementException)
Expand Down